OpenRFPerm
OpenRFPerm
Open resource file, specifying permission level ConstStr255Param fileName ; address of length-prefixed filename
short vRefNum ; volume/directory reference number short permission ; read/write permission code
returns file reference number (or -1 if error)
OpenRFPerm can be used the first time a resource file is opened. It is similar to OpenResFile except that it allows you to specify in which volume/directory to find the file and you can set a file's read/write permission
level for subsequent access.
fileName is the address of a Pascal-style length-prefixed filename identifying
the file containing the resources you want to access. It may contain a
full or partial pathname.
vRefNum specifies the volume or directory reference number identifying where the file resides.
permission specifies the desired read/write permission code to be set for the
file. It may be one of:
fsCurPerm 0 No change from existing file permission
fsRdPerm 1 Read only
fsWrPerm 2 Write only
fsRdWrPerm 3 Read and write
fsRdWrShPerm 4 Read and write, shared access
Returns: an integer; -1 indicates an error. Otherwise, it is the file reference number which must be used in subsequent resource file
operations.
Notes: Inside Macintosh Volume 4, page 17 states that
it simply returns the reference number already assigned to the file. In
other words, OpenRFPerm cannot be used to open a second access path to a resource file
This is not correct. Under MultiFinder, OpenRFPerm behaves exactly as described if the application attempts to open a second path with write
access. That is, it returns a -1 and sets ResError to opWrErr (-49). But OpenRFPerm will create multiple, unique, read-only access paths to a resource file (under Finder or MultiFinder). This feature is not safe since
if a resource file is opened twice, once with read-write permission and
once with read-only permission, it is possible to get the resource maps in
an inconsistent state.
OpenRFPerm behaves exactly as described if an application attempts to open a second path, with write access, to a resource file without
MultiFinder. With MultiFinder, however, if the second attempt comes from a
different application than the first one, OpenRFPerm will not return the reference number already assigned to the resource file, instead it will
return a -1 and ResError will be set to opWrErr (-49).