Trying to C a directory.

Steve Summit scs at adam.pika.mit.edu
Sun May 28 11:19:27 AEST 1989


In article <236100013 at mirror> root at mirror.TMC.COM (Patrick McCartney) writes:
>I am having trouble trying to figure out how to read a directory in
>MS-DOS.  I would like to be able to read in the directory contents...

In article <708 at marob.masa.com> manes at marob.masa.com (Steve Manes) writes:
>Why I Like Turbo-C: it has the two functions you need, findfirst and
>findnext, already in the libraries.  There's also an example.
>Alternatively, you will essentially need to recreate these functions
>with DOS service calls.

If you are at all interested in portability, the functions you
need are called opendir, readdir, and closedir, which neither
Microsoft nor (apparently) Borland have seen fit to provide.
These routines are in the POSIX standard and are the universally
recommended way of reading directories from within a C program.
Several implementations of MS-DOS opendir/readdir exist: I have
written one or two, which I can supply upon request; I have given
mine to Doug Gwyn for inclusion in his posted opendir/readdir
package; I have also heard that the FSF has an implementation so
that their tools can be ported to MS-DOS (if you have enough
memory :-) ).

                                            Steve Summit
                                            scs at adam.pika.mit.edu



More information about the Comp.lang.c mailing list