List a directory in a C program on Unix machines
CAO YUSONG
cys at caen.engin.umich.edu
Sun Aug 12 15:58:34 AEST 1990
In article <159 at smds.UUCP> rh at smds.UUCP (Richard Harter) writes:
>In article <1990Aug10.213953.25619 at cubmol.bio.columbia.edu>, ping at cubmol.bio.columbia.edu (Shiping Zhang) writes:
>> In article <1990Aug10.154506.846 at caen.engin.umich.edu> cys at caen.engin.umich.edu writes:
>> > I am currently writing a C program on Unix machines. What I want to
>> >do is to store the file names in a directory into a character array.
>> >So I can do something to those files. I want to use Unix system calls
>> >to handle it. Could anyone help me out with that?
>
>> I think opendir(), readdir() etc. can handle this problems. Check
>> your man pages.
>
>But be warned. There are some portability pitfalls so the routine to
>fetch the file names should be encapsulated. The major variants that
>I can think of offhand are:
>
>(a) BSD Uses <sys/dir.h>
>(b) SYS V Uses <dirent.h>
>(c) SYS V Older versions of SYS V may not have these routines.
> You can write your own. THe directory is a file
> containing an array of structures which can be read.
> The format is in the manual.
>(d) VMS Write your own. There are C callable VMS library
> routines for extracting the needed information.
>(e) Primos Has a routine called lsdir which returns just what
> you want.
>
>
>--
>Richard Harter, Software Maintenance and Development Systems, Inc.
>Net address: jjmhome!smds!rh Phone: 508-369-7398
>US Mail: SMDS Inc., PO Box 555, Concord MA 01742
>This sentence no verb. This sentence short. This signature done.
Thanks everyone who replied my message. You guys are really fantastic!
More information about the Comp.lang.c
mailing list