![]() |
CITS2002 Systems Programming |
← prev | next → | ![]() |
![]() |
|||
Reading the contents of a directoryMost modern operating systems store their data in hierarchical file systems, consisting of directories which hold items that, themselves, may either be files or directories.The formats used to store information in directories in different file-systems are different(!), and so when writing portable C programs, we prefer to use functions that work portably. Consider the strong similarities between opening and reading a (text) file, and opening and reading a directory:
With directories, we're again discussing functions that are not part of the C11 standard, but are defined by POSIX standards. The inconsistent naming of system-defined datatypes - for example, struct dirent versus DIR - can be confusing (annoying) but, over time, renaming datatypes across billions of lines of open-source code becomes impossible.
CITS2002 Systems Programming, Lecture 16, p6, 19th September 2023.
|