HOpenResFile
HOpenResFile Open resource file by vRefNum, ID; get reference number
#include <Resources.h> Resource Manager
short HOpenResFile( vRefNum, dirID, fileName, permission );
short vRefNum ; volume reference number
long dirID ; directory ID for directory where file is
located
ConstStr255Param fileName ; address of length-prefixed filename
char permission ; permission bits
returns reference number of the file (or -1 if an error)
The HOpenResFile function opens the resource file with the name given by
the fileName parameter. This function also lets you open a resource file
without creating a working directory. Call the ResError function to check for
errors. If HOpenResFile failed to open the resource file, the reference
number returned is -1.
The vRefNum parameter contains the volume reference number of the volume
on which the file is located. The dirID parameter contains the directory ID of
the directory where the file is located. The constants used for the permission
parameter are the same as those listed for the FSpOpenResFile function.
HOpenResFile works the same way as OpenResFile except it works on a
vRefNum and a dirID instead of a file name. HOpenResFile is designed for use
with HFS files. HOpenResFile opens the specified resource file, reads its
resource map into memory and returns a file reference number for that
file. The specified file becomes the current active resource file (unless it is
already open). This routine also lets you open a resource file without creating
a working directory.
The FSpOpenResFile and HOpenResFile functions are alternate ways of
opening resource files using HFS. These functions are based on the
OpenResFile function, which is documented in Inside Macintosh Volume I.
HOpenResFile is a simple function designed for HFS; FSpOpenResFile
uses file system specification records.
vRefNum is the volume reference number of the volume on which the file is
located.
dirID is the directory ID of the directory where the file is located.
fileName is the address of a Pascal-style length-prefixed filename. It may
contain volume and directory names; if omitted, the working
directory is assumed.
permission specified the kind of access path permission you want. In most
cases, you can simply set the permission parameter to fsCurPerm.
See the Notes section below for additional information on the
permission parameter.
Returns: an integer; -1 indicates that HOpenResFile failed to open the file.
Otherwise, it is the file reference number which must be used in
subsequent resource file operations. Call the ResError function to
check for one of the following Resource Manager errors.
Returns: an Error Code. It will be one of:
nsvErr (-35) No such volume
ioErr (-36) I/O error
bdNamErr (-37) There may be no bad names in the final system
eofErr (-39) End of file
tmfoErr (-42) Too many files open
fnfErr (-43) File not found
opWrErr (-49) File already open with write permission
permErr (-54) Permissions error (on file open)
extFSErr (-58) Volume belongs to an external file system
memFullErr (-108) Not enough room in heap zone
dirNFErr (-120) Directory not found
mapReadErr (-199) Map inconsistent with operation

Notes: HOpenResFile takes a permission parameter
It should be one of the following values:
fsCurPerm whatever is currently allowed
fsRdPerm exclusive read permission
fsWrPerm exclusive write permission
fsRdWrPerm exclusive read/write permission
fsRdWrShPerm shared read/write permission
In shared environments, permission requests are translated into the
"deny-mode" permissions defined by AppleShare.