Important: The information in this document is obsolete and should not be used for new development.
WriteResource
You can use theWriteResource
procedure to write resource data in memory immediately to a file's resource fork. Note thatWriteResource
does not write the resource's resource map entry to disk.
PROCEDURE WriteResource (theResource: Handle);
theResource
- A handle to a resource.
DESCRIPTION
Given a handle to a resource,WriteResource
checks theresChanged
attribute of that resource. If theresChanged
attribute is set to 1 (after a successful call to theChangedResource
orAddResource
procedure),WriteResource
writes the resource data in memory to the resource fork, then clears theresChanged
attribute in the resource's resource map in memory.
If the resource is purgeable and has been purged,
- Note
- When your application calls
ChangedResource
orAddResource
, the Resource Manager attempts to reserve disk space for the changed resource. If the modified resource data can't be written to the resource fork (for example, if there's not enough room on disk), theresChanged
attribute is not set to 1. If this is the case and you callWriteResource
, the Resource Manager won't know that the resource data has been changed. Thus, the routine won't write the modified resource data to the resource fork and won't return an error. For this reason, always make sure that theResError
function returns the result codenoErr
after a call toChangedResource
orAddResource
.WriteResource
writes zero-length resource data to the resource fork. If the resource'sresProtected
attribute is set to 1,WriteResource
does nothing, and theResError
function returns the result codenoErr
. The same is true if theresChanged
attribute is not set (that is, set to 0). If the given handle isn't a handle to a resource,WriteResource
does nothing, andResError
returns the result coderesNotFound
.The resource fork is updated automatically when your application quits, when you
callUpdateResFile
, or when you callCloseResFile
(which in turn callsUpdateResFile
). Thus, you should callWriteResource
only if you want to write just one or a few resources immediately.RESULT CODES
noErr 0 No error resNotFound -192 Resource not found SEE ALSO
To check for errors, call theResError
function as described on page 1-47.For more information about resource attributes, see "The Resource Map" beginning on page 1-7. For descriptions of the
ChangedResource
andAddResource
procedures,
see page 1-83 and page 1-85, respectively. For a description of theUpdateResFile
procedure, see page 1-87. For a description of theCloseResFile
procedure, see page 1-104.