Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!AppleLink.Apple.Com!Greg From: Greg@AppleLink.Apple.Com (Greggy) Newsgroups: comp.sys.mac.programmer Subject: Re: Config File Resource Blues Message-ID: <2741@internal.Apple.COM> Date: 10 Jul 89 21:55:59 GMT Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 47 References:<2013@dogie.macc.wisc.edu> <1165@intercon.UUCP> In article <1165@intercon.UUCP> amanda@intercon.uu.net (Amanda Walker) writes: > There's another approach, which I use and have never had any problems > with, and goes something like this: > > read_settings: > OpenResFile // open the settings file > GetResource // get settings resource > DetachResource // detach it from the resource map > CloseResFile // close the settings file > > at this point, my settings resource is just another handle, which I can > dispose of after I'm done with it. > > write_settings: > CreateResFile (if it's not already there) > OpenResFile // open the settings file > if (GetResource) // if there's an old setting resource, > RmveResource // remove it > AddResource // add the current settings as a resource > CloseResFile // close the settings file > > This way, I don't have to worry about the resource changing size, or > whatever. As another trick, you can put a default settings resource in > your application, so that you don't have to worry about the settings file > not being there the first time. You could even SetResLoad( FALSE ) before the GetResource call in write_settings to prevent the old settings from needing some of your precious heap space right before you nuke them! > -- > Amanda Walker > InterCon Systems Corporation > amanda@intercon.uu.net | ...!uunet!intercon!amanda > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Greg Marriott + AppleLink: Greg + + Just Some Guy + + + "My phone is always busy" + Internet: Greg@AppleLink.Apple.Com + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Apple Computer, Inc. + + 20525 Mariani Ave, MS-46z, Cupertino, CA 95014 + + (408)974-busy + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++