GG.DAR@forsythe.stanford.edu (Aaron Reizes) (10/23/89)
Working Directory from SFGetFile. I know this has been hashed about before, but I don't seem to have backlogs of the items. How do I set a working directory (OpenWD call) from the Reply information from SFGetFile or SFPutFile? I think this relates to a problem I am having: I save a file to a folder. A previous copy of this file in the System Folder (same name) gets deleted. How come? Also is there a good reference book on the Mac File System? Something that normal mortal humans can understand as opposed to the descriptions in IM? Thanks, in advance, Aaron Reizes reizes@forsythe.stanford.edu
lsr@Apple.COM (Larry Rosenstein) (10/24/89)
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