Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!samsung!brutus.cs.uiuc.edu!apple!apple.com!chewy From: chewy@apple.com (Paul Snively) Newsgroups: comp.sys.mac.programmer Subject: Re: Simple File Manager Question Message-ID: <7452@goofy.Apple.COM> Date: 29 Mar 90 18:21:14 GMT Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 62 References:<7726@b11.ingr.com> <8751@tekigm2.MEN.TEK.COM> In article <8751@tekigm2.MEN.TEK.COM> gregr@tekigm2.MEN.TEK.COM (Gregory S Rogers) writes: [Stuff about why GetFInfo on a WDRefNum doesn't fail if a file with the same name happens to live in the System Folder.] The good news is that your question isn't as simple as you think, i.e. it's not a "stupid" question at all. The bad news is that you're being bitten by a little-known and even less understood feature of HFS called the Poor Man's Search Path (PMSP). Somewhere down in low RAM, there is a list of vRefNums and dirIDs. Whenever most of the file manager routines are called (including GetFInfo), the file manager will check the first vRefNum/dirID pair in the list. If the file is there, you'll get that info. If not, it tries the next pair, etc. until it either succeeds or runs out of pairs (resulting in a fnfErr). Under normal conditions, there are only two pairs in the list: the first is whatever was specified in the call, and the second is the vRefNum/dirID of the blessed folder. So if the file isn't in the place you specified, but is in the blessed folder, sure enough, GetFInfo will tell you about it. Several years ago, I wrote a DA/INIT combination called "Set Paths" that gives you explicit control over the PMSP list; it allows you to specify up to five folders to be searched. It's easily the ugliest hack that I've ever written. There is at least one Tech Note on this subject. Unfortunately I do not have my Tech Notes in front of me, so I cannot point you to the exact one. If you have the Tech Note index, I'd recommend looking up "HFS," or if you're lucky, "PMSP" will be in the index as well. There are a couple of workarounds: after calls like GetFInfo, compare the vRefNum and dirID against what you passed (breaking down the WDRefNum by using GetWDInfo, if necessary) and, if they don't match, take the results with a grain of salt (or be really picky and compare the results against whatever SysEnvirons tells you the WDRefNum of the blessed folder is). The overhead for this might be unacceptable. Another workaround is to find the appropriate Tech Note, which documents a one-time "don't use the PMSP" capability. You can also just plain turn the PMSP off (don't forget to turn it back on again after you're done, please). Hope this helps, at least a little! __________________________________________________________________________ Paul Snively Macintosh Developer Technical Support Apple Computer, Inc. 1st Choice: Paul_Snively.DTS@qm.gateway.apple.com 2nd Choice: CHEWBACCA@applelink.apple.com Last Choice: chewy@apple.com Just because I work for Apple Computer, Inc. doesn't mean that I believe what they believe, or vice-versa. __________________________________________________________________________