At the risk of derailing our derailed conversation, I'm curious if I could get feedback on another issue I'm running into.
In brief, the codebase is using FSpOpenResFile and FSpCreateResFile, which are System 7+ functions. I'm trying to figure out how to correctly create and open a resource file on a HFS system with System 6.
I found
MoreFiles which is a helpful set of tools provided by Apple Macintosh Developer Technical Support that adds some backwards compatibility with the new System 7 FFSpec based functions but their FSp*ResFile functions just fall back to H*ResFile functions that are also limited to System 7+.
Reading up on FSpOpenResFile and FSpCreateResFile.
IM 6 13-16
These routines are based on the CreateResFile procedure, which is documented in the Resource Manager chapter of Volume I.
These functions are based on the OpenResFile function, which is documented in Volume I.
Looking at CreateResFile and OpenResFile
IM 1-114
When calling the CreateResFile or OpenResFile routine, described below, you specify a resource file by its file name; the routine assumes that the file has a version number of 0 and is on the default volume.
...
If you want the routine to apply to a file on another volume, just set the default volume to that volume
IM 4-107
SetVol sets the default volume to the mounted volume specified by volName or vRefNum.
IM 4-98 Working Directories
When the File Manager makes a particular directory a working directory (using the function OpenWD), it stores the directory ID, as well as the volume reference number of the volume on which the directory is located, in a working directory control block. The File Manager then returns a unique working directory reference number which you can use in subsequent calls to refer to that directory.
...
Directories can be seen as mini-volumes. (The root directory is, in fact, just another mini volume; it contains only the files and directories immediately below it in the tree structure.) A working directory reference number is just like a volume reference number for a directory.
...
A working directory reference number can be used in place of a volume reference number in any File Manager call.
So as I think I understand it, in theory, I would do the following:
- Call GetVolInfo to restore when we are done; check for error
- Get the vRefNum of the applicable directory (hand waving here)
- Call OpenWD with the vRefNum of applicable directory; check for error
- Call SetVol with a vRefNum returned from OpenWD; check for error
- Call CreateResFile with the name of the file I want to create; check for ResError
- Call OpenResFile with the name of the file just created; check for ResError (may be able to use OpenRFPerm as well)
- Do stuf
- Call CloseResFile; check for ResError
- Call CloseWD; check for error
- Call SetVol with info at go beginning of routine to restore the previous working volume; check for error
Is that correct? Do I need to do the GetVol/SetVol dance, or does OpenWD handle that already?