Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!mips!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: opendir() and readdir() Message-ID: <37507@apple.Apple.COM> Date: 26 Dec 89 06:57:34 GMT References: <2618@draken.nada.kth.se> Organization: Apple Computer Inc, Cupertino, CA Lines: 34 In article <2618@draken.nada.kth.se> h+@nada.kth.se (Jon W{tte) writes: > >It's that time of the year again. > >I simply want to get the names of the files in adirectory. >No, I am no novice to mac programming, but I've let libraries >handle file I/O for me until now. I looked through IM IV, but >the HFS chapter is less than crystal clear on this point... > >Now, how do I search {a | the current} directory for file >names (and maybe types...) ? Any code pieces or hints are >welcome ! Jon, Macintosh Technical Note #68 discusses the algorithm for looking at all entries in a directory, including sub-directories if you wish. It is slightly deficient in that it does not handle well situations where your directory may change out from under you. This could happen, say, on an AppleShare volume. John Norstad looked into this situation deeply, and came up with a modified algorithm that re-syncs if it finds that things have changed. If he is reading this, perhaps he could re-post his article. By the way, Inside Mac IV should be pretty clear on this. Most of page IV-101 talks about indexed calls. These include calls like PBGetVolInfo, PBGetFInfo, and PBGetCatInfo. PBGetCatInfo is the routine used in the Technote. -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions