lsr@apple.UUCP (Larry Rosenstein) (09/03/85)
In article <2298@sdcrdcf.UUCP> dennisg@sdcrdcf.UUCP (Dennis Griesser) writes: >One the same subject, how can an application tell what files reside on a disk? >Even CP/M-80 allowed you to open with "ambigous file references" (wildcards), >but it seems that Mac programmers must read the disk directory. > >Is there a better way to find out what's on a disk? > You can enumerate all the available volumes and all the files on a volume using File Manager calls. With GetFInfo, for example, you can specify the file with an index (the ioFDirIndex field). To enumerate all the files on a volume, start with index 1 and continue until you receive a fnfErr back. With this technique you do not have to understand the format of directories on a volume. If you are wondering about performance, the file system has an optimization to handle this particular case, so that it does not always search from the very start of the directory. Also, you can eliminate the overhead of the trap dispatcher by getting the address of the GetFInfo trap outside the loop, and doing a JSR to this address instead of calling the trap. -- Larry Rosenstein Apple Computer UUCP: {voder, idi, nsc, ios, mtxinu, dual}!apple!lsr CSNET: lsr@Apple.CSNET