ansi c and directories

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Nov 25 03:18:21 AEST 1989


In article <1848 at ntmtka.mn.org> mike at ntmtka.mn.org (Mike Tietel) writes:
>In article <13295 at s.ms.uky.edu>, beech at ms.uky.edu (Wayne Beech) writes:
>> what i was getting at was most programs perform their work on files so it
>> looks like there would have been something mentioned in the standard about
>> handling routine actions on file systems, things like how do you get the
>> names of files in a directory( or on a minidisk).

Although I have reasonable, standard functions for accessing
directories, I find that it is quite rare for programs to use them.
The main reason for this seems to be that pathnames are generally
provided as arguments to programs, so they have no need to rummage
around in directories.  The exception is for user interface programs
(shells, desktop finders, etc.) which of course are expected to be
able to display contents of directories, perhaps via menus.

Thus, while it is quite important for C applications to be able to
access files by name, it is much less important for them to be able
to access the contents of directories.  Also, many systems either do
not HAVE directories (although they do have named files) or their
directories contain much important information that is too system-
specific to allow for in the universal C standard.

IEEE Std 1003.1-1988 (POSIX system interface) does specify a set of
standard directory access functions that work reasonably well in most
UNIX-like contexts.  Kirk McKusick of UCB published an earlier, not
quite POSIX-compatible, implementation and I've been providing a
fully POSIX-compliant public-domain implementation for UNIX variants.
Others have adapted these or provided equivalents for non-UNIX systems.
Thus, the POSIX directory access functions are about as standard as you
can get.



More information about the Comp.lang.c mailing list