Xref: utzoo comp.sys.att:2487 comp.sys.misc:1140 Path: utzoo!utgpu!water!watmath!clyde!rutgers!umd5!purdue!gatech!hao!oddjob!gargoyle!ihnp4!ihlpe!psfales From: psfales@ihlpe.ATT.COM (Pete Fales) Newsgroups: comp.sys.att,comp.sys.misc Subject: Re: Seeking a method to "read" a DOS directory Message-ID: <2639@ihlpe.ATT.COM> Date: 12 Feb 88 15:12:35 GMT References: <902@cblpe.ATT.COM> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 32 In article <902@cblpe.ATT.COM>, jrm@cblpe.ATT.COM (John Miller) writes: > I would like obtain a list of files that are in a DOS directory using > Microsoft 'C', version 4 or 5. Near as I can tell, you are not permitted > to "open" a directory in dos. Further, I have not been able to find a > function in the MSC library, or a function in the DOS or BIOS library > that will permit me to find out what files are in a given directory. > > The best method I know of so far (and this is more of an attack plan than > a sure and tried solution) - is to use a DOS interrupt function to gain > information about the FAT. From that information, I should be able to > calculate the location, on disk, of the beginning sector containing > the DOS directory table. Once in the table, I should be able to traverse > through the chains to find all the files that are in the directory I > am interested in. There is a better way! Some compilers have library routines to do this (my Ecosoft compiler, for example) but that doesn't help you much if yours doesn't. Take a look at the DOS functions "find first" and "find next." These functions take a complete path name (including wild cards) and return all files that match the template. If you give it a path name terminating in *.*, it will find all the files in the directory. There are bits you can set in the paramter block to include/exclude subdirectories and hidden or system files. This should do what you want in a much more device independent manner. Pete -- Peter Fales UUCP: ...ihnp4!ihlpe!psfales work: (312) 979-7784 AT&T Information Systems, IW 1Z-243 1100 E. Warrenville Rd., IL 60566