Path: utzoo!attcan!uunet!cs.utexas.edu!samsung!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: ansi c and directories Message-ID: <11681@smoke.BRL.MIL> Date: 24 Nov 89 16:18:21 GMT References: <13295@s.ms.uky.edu> <1848@ntmtka.mn.org> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 30 In article <1848@ntmtka.mn.org> mike@ntmtka.mn.org (Mike Tietel) writes: >In article <13295@s.ms.uky.edu>, beech@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.