3 ms·
It's built into the semantics of the OS. Unix directories are ordinary files, treated specially. They can be opened and read (and written to) like any file. If
by bitwize 5y ago
It's built into the semantics of the OS. Unix directories are ordinary files, treated specially. They can be opened and read (and written to) like any file. If you have a more primitive pager than less, you can sometimes see this by running it on a directory; you will see binary garbage with file names embedded in it, like whole pieces of corn in a turd.
That said, if your HLL doesn't provide a better abstraction when reading a directory with the standard file I/O primitives, it is indeed a serious bug in the language. Don't do that, language designers and standard library authors!