Important: The information in this document is obsolete and should not be used for new development.
Using the Resource Manager
You use the Resource Manager to perform operations on resources. To determine whether certain features of the Resource Manager are available (support forFSSpec
records and partial resources), use theGestalt
function.Two commonly used Resource Manager routines use a file system specification (
FSSpec
) record: theFSpCreateResFile
procedure and theFSpOpenResFile
function. These routines are available only in System 7 or later. Call theGestalt
function with thegestaltFSAttr
selector to determine whether the Resource Manager routines that useFSSpec
records exist. If the bit indicated by the constantgestaltHasFSSpecCalls
is set, then the routines are available.
CONST gestaltFSAttr = 'fs '; {Gestalt selector for } { File Mgr attributes} gestaltHasFSSpecCalls = 1; {check this bit in the } { response parameter}In addition, the Resource Manager routines for reading and writing partial resources are available only in System 7 or later versions of system software. Use theGestalt
function to determine whether these features are available. Call theGestalt
function with thegestaltResourceMgrAttr
selector to determine whether the routines for handling partial resources exist. If the bit indicated by the constantgestaltPartialRsrcs
is set, then the Resource Manager routines for handling partial resources are available. For more information about theGestalt
function, see Inside Macintosh: Operating System Utilities.
CONST gestaltResourceMgrAttr = 'rsrc'; {Gestalt selector for } { Resource Mgr attributes} gestaltPartialRsrcs = 0; {check this bit in the } { response parameter}You can use theResError
function to retrieve errors that may result from calling Resource Manager routines. Resource Manager procedures do not report error information directly. Instead, after calling a Resource Manager procedure your application should call theResError
function to determine whether an error occurred.Resource Manager functions usually return
NIL
or -1 as the function result when there's an error. For Resource Manager functions that return -1, your application can call theResError
function to determine the specific error that occurred. For Resource Manager functions that return handles, your application should always check whether the value of the returned handle isNIL
. If it is, your application can useResError
to obtain specific information about the nature of the error. Note, however, that in some casesResError
returnsnoErr
even though the value of the returned handle isNIL
.The rest of this section describes how to create a resource using ResEdit or the Rez resource compiler. It then describes how to use Resource Manager routines to
For detailed descriptions of all Resource Manager routines, see "Resource Manager Reference" beginning on page 1-36. For information on writing data to a file's data fork, see Inside Macintosh: Files.
- get a handle to a resource and modify a purgeable resource safely
- release and detach resources
- create and open a resource fork
- set the current resource file (the file whose resource fork the Resource Manager searches first)
- read and manipulate resources
- write resources
- read and write partial resources
Subtopics
- Creating a Resource
- Getting a Resource
- Releasing and Detaching Resources
- Opening a Resource Fork
- Reading and Manipulating Resources
- Writing Resources
- Working With Partial Resources