reading directory under SYSTEM V

Barry Shein bzs at bu-cs.BU.EDU
Sun Sep 7 08:43:30 AEST 1986


>> 
>> Cound anybody suggest a method of reading directory information from a C
>> program under SYSTEM V UNIX? I need something equivalent to the opendir and 
>> readdir functionality supplied under BSD.

>Ditto.
>
>Clayton E. Cramer

This may not thrill you, but have you considered forking an 'ls' into
a tmp file and reading that back? (or, similarly, using a popen() to
ls)?

It's not all that slow and shure is portable. I was happy I did that
with a program I wrote back in the old days that just came up on
various versions (consider the number of 'ls's done on your system
anyhow...) And you can even sort them this way and that trivially
(I presume by "functionally" above you mean you end up with the file
names, not the subroutine interface, if you're just trying to move
an application using the 4.2 calls this is not as helpful but it
wouldn't be crazy to implement them conditionally in terms of calls
to 'ls', shouldn't be hard.)

	-Barry Shein, Boston University



More information about the Comp.lang.c mailing list