Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!apple!Apple.COM!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Setting Working Directory Message-ID: <4841@internal.Apple.COM> Date: 23 Oct 89 18:47:46 GMT References: <5315@lindy.Stanford.EDU> Sender: usenet@Apple.COM Organization: Objects-R-Us, Apple Computer, Inc. Lines: 39 In article <5315@lindy.Stanford.EDU> GG.DAR@forsythe.stanford.edu (Aaron Reizes) writes: > I save a file to a folder. A previous copy of this file in the > System Folder (same name) gets deleted. How come? The File Manager has a feature in which it looks in the System Folder if it can't find the file you explicitly asked for. (This is called the Poor Man's Search Path.) You have to be careful of this feature if you perform a File Manager call and don't know if the file exists or not, for the reason you noticed. For example, if you save a file by deleting the original (in case it exists) and saving the new version, then you will get the behavior you described. The Delete call uses the PMSP, so if the file doesn't exist, you may delete a version found in the System Folder. Pretty much all calls that apply to files use the PMSP EXCEPT for Create. In particular, you can't get information about the file because it uses the PMSP. So one way to solve the problem is to call Create (to create the file if it doesn't exist) and delete the original only if the Create returns "duplicate file name" as the error. Another technique (used in MacApp) is to always put an explicit dirID in the parameter block. If there is an explicit dirID, then the File Manager assumes you know what you are doing and doesn't use the PMSP. You can use the call PBGetWDInfo to turn a workind directory refnum into a pure volume refnum and a dirID. It shouldn't be necessary for you to open a working directory to solve this particular problem. (Standard File will do that for you.) Larry Rosenstein, Apple Computer, Inc. Object Specialist Internet: lsr@Apple.com UUCP: {nsc, sun}!apple!lsr AppleLink: Rosenstein1