Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!caen!blue.engin.umich.edu!cys From: cys@caen.engin.umich.edu (CAO YUSONG ) Newsgroups: comp.lang.c Subject: Re: List a directory in a C program on Unix machines Message-ID: <1990Aug12.055834.681@caen.engin.umich.edu> Date: 12 Aug 90 05:58:34 GMT References: <1990Aug10.154506.846@caen.engin.umich.edu> <1990Aug10.213953.25619@cubmol.bio.columbia.edu> <159@smds.UUCP> Sender: news@caen.engin.umich.edu (CAEN Netnews) Distribution: usa Organization: University of Michigan Engineering, Ann Arbor Lines: 34 In article <159@smds.UUCP> rh@smds.UUCP (Richard Harter) writes: >In article <1990Aug10.213953.25619@cubmol.bio.columbia.edu>, ping@cubmol.bio.columbia.edu (Shiping Zhang) writes: >> In article <1990Aug10.154506.846@caen.engin.umich.edu> cys@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 >(b) SYS V Uses >(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!