[comp.sys.mac.programmer] file system calls and resource file calls

korfhage@lanai.cs.ucla.edu (05/20/89)

   I have some simulations in which I write results to a file, then add a
Disktop-readable comment (a CEKI resource) with simultion parameters.
However, I use SFPutFile to get the file name, and that gives me a name and
a directory reference. When I open up the file to write in the CEKI
resource, the call (e.g.  CreateResFile) wants an absolute pathname, and
not a name-and-directory-reference.
   That wouldn't be troubling, except that I don't see any convenient way
to convert a name-and-directory-reference into an absolute path name.
Plenty of program do this, so what's the trick?
   Alternatively, I could use OpenRF to open the resource fork, but the
implication in _Macintosh_Revealed_ is that I will have to do some
extra housekeeping myself if I use OpenRF instead of OpenResFile and its kin.
Is this so?
   The former (conversion) would be preferable to the latter (new calls)
because I already have working code that uses the XXXResFile calls.

   Thanks for any help.

   Willard Korfhage

   ARPA : korfhage@cs.ucla.edu
   UUCP : {ucbvax,randvax,trwrb!trwspp,ism780}!ucla-cs!korfhage

lsr@Apple.COM (Larry Rosenstein) (05/23/89)

In article <24103@shemp.CS.UCLA.EDU> korfhage@lanai.cs.ucla.edu writes:
> However, I use SFPutFile to get the file name, and that gives me a name 
and
> a directory reference. When I open up the file to write in the CEKI
> resource, the call (e.g.  CreateResFile) wants an absolute pathname, and
> not a name-and-directory-reference.

The easiest thing to do is to call SetVol to set the current directory to 
the one returned by Std File, and then use the filename in the 
CreateResFile call.  (You may want to precede this by a call to GetVol to 
save the old current directory.)

You will also want to consult Tech Notes 101 & 214.  101 explains that you 
should call the Create function first, to create the file, before calling 
CreateResFile.  The reason is that CreateResFile tries to open the 
resource file first, but because of the Poor Man's Search Path it may find 
a file with the same name in the System Folder.

Tech Note 214 describes new MPW glue routines that do this stuff for you.

Larry Rosenstein, Apple Computer, Inc.
Object Specialist

Internet: lsr@Apple.com   UUCP: {nsc, sun}!apple!lsr
AppleLink: Rosenstein1