Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Yikes: Using both resource & data forks of a file Message-ID: <51648@apple.Apple.COM> Date: 17 Apr 91 23:43:10 GMT References: <0B01FFFF.dbbnhif@tbomb.ice.com> <1991Apr17.134645.2516@ux1.cso.uiuc.edu> Organization: Future Stuff, Apple Computer, Inc. Lines: 23 In article <1991Apr17.134645.2516@ux1.cso.uiuc.edu> dorner@pequod.cso.uiuc.edu (Steve Dorner) writes: > >Since I almost always end up using the resource forks of files I create >(window position info, for one), I ALWAYS use CreateResFile, not Create, >to create files. I then don't have to do any special monkeying around to There's a serious problem with this approach, which is described in Tech Note 101. Briefly, CreateResFile first checks to see if the resource file exists, by calling OpenResFile, so it can return an error. Unfortunately, OpenResFile will use the Poor Man's Search Path. So if you try to create a resource file with the same name as one in the System Folder, it will return an error. The solution is to always call Create (which doesn't use the PMSP) to create the file, and then CreateResFile to create the resource fork. (BTW, an empty resource fork only contains a hundred bytes or so, but it can occupy quite a bit of space depending on the allocation block size of your disk.) -- Larry Rosenstein, Apple Computer, Inc. lsr@apple.com (or AppleLink: Rosenstein1)