Important: The information in this document is obsolete and should not be used for new development.
UpdateResFile
You can use theUpdateResFile
procedure to update the resource map and resource data for a resource fork without closing it.
PROCEDURE UpdateResFile (refNum: Integer);
refNum
- A file reference number for a resource fork.
DESCRIPTION
Given the reference number of a file whose resource fork is open,UpdateResFile
performs three tasks. The first task is to change, add, or remove resource data in the
file's resource fork to match the resource map in memory. Changed resource data for each resource is written only if that resource'sresChanged
bit has been set by a successful call toChangedResource
orAddResource
. TheUpdateResFile
procedure calls theWriteResource
procedure to write changed or added resources to the resource fork.The second task is to compact the resource fork, closing up any empty space created when a resource was removed, made smaller, or made larger. If a resource is made larger, the Resource Manager writes it at the end of the resource fork rather than at its original location. It then compacts the space occupied by the original resource data. The actual size of the resource fork is adjusted when a resource is removed or made larger, but not when a resource is made smaller.
The third task is to write the resource map in memory to the resource fork if your application has called the
ChangedResource
procedure for any resource listed in the resource map or if it has added or removed a resource. All changes to resource information in the resource map become permanent at this time; if you want any of these changes to be temporary, you must restore the original information before callingUpdateResFile
.If there's no open resource fork with the given reference number,
UpdateResFile
does nothing, and theResError
function returns the result coderesNotFound
. If the value of therefNum
parameter is 0, it represents the System file's resource fork. If you callUpdateResFile
but themapReadOnly
attribute of the resource fork is set,UpdateResFile
does nothing, and theResError
function returns the result coderesAttrErr
.Because the
CloseResFile
procedure callsUpdateResFile
before it closes the resource fork, you need to callUpdateResFile
directly only if you want to update the file without closing it.RESULT CODES
noErr 0 No error resNotFound -192 Resource not found resAttrErr -198 Attribute inconsistent with operation SEE ALSO
To check for errors, call theResError
function as described on page 1-47.For an example of the use of
UpdateResFile
, see Listing 1-11 on page 1-32. For descriptions of theChangedResource
,AddResource
, andCloseResFile
procedures, see page 1-83, page 1-85, and page 1-104, respectively. TheWriteResource
procedure is described next.