Important: The information in this document is obsolete and should not be used for new development.
UpdateResFile
You can use theUpdateResFileprocedure 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,UpdateResFileperforms 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'sresChangedbit has been set by a successful call toChangedResourceorAddResource. TheUpdateResFileprocedure calls theWriteResourceprocedure 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
ChangedResourceprocedure 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 theResErrorfunction returns the result coderesNotFound. If the value of therefNumparameter is 0, it represents the System file's resource fork. If you callUpdateResFilebut themapReadOnlyattribute of the resource fork is set,UpdateResFiledoes nothing, and theResErrorfunction returns the result coderesAttrErr.Because the
CloseResFileprocedure callsUpdateResFilebefore it closes the resource fork, you need to callUpdateResFiledirectly 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 theResErrorfunction 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, andCloseResFileprocedures, see page 1-83, page 1-85, and page 1-104, respectively. TheWriteResourceprocedure is described next.