Important: The information in this document is obsolete and should not be used for new development.
WritePartialResource
You can use theWritePartialResourceprocedure to write part of a resource to disk when working with a small subsection of a large resource.
PROCEDURE WritePartialResource (theResource: Handle; offset: LongInt; buffer: UNIV Ptr; count: LongInt);
theResource- A handle to a resource.
offset- The beginning of the resource subsection to write, measured in bytes
from the beginning of the resource.buffer- A pointer to the buffer containing the data to write.
count- The length of the resource subsection to write.
DESCRIPTION
TheWritePartialResourceprocedure writes the data specified by thebufferparameter to the resource subsection identified by thetheResource,offset, andcountparameters. Your application is responsible for the buffer's memory management.If the disk or the file is locked, the
ResErrorfunction returns an appropriate File Manager result code. If you try to write past the end of a resource, the Resource Manager attempts to enlarge the resource. TheResErrorfunction returns the result codewritingPastEndif the attempt succeeds. If the Resource Manager cannot enlarge the resource,ResErrorreturns an appropriate File Manager result code. If you pass an invalid value in theoffsetparameter,ResErrorreturns the result codeinputOutOfBounds.The
WritePartialResourceprocedure tries to write the data from the buffer to disk. If the attempt is successful and the resource data (referenced through the resource's handle) is in memory,ResErrorreturns the result coderesourceInMemory. In this situation, be aware that the data of the resource subsection on disk matches the data from the buffer, not the resource data referenced through the resource's handle. If the attempt to write the data from the buffer to the disk fails,ResErrorreturns an appropriate error.When using partial resource routines, you should call the
SetResLoadprocedure, specifyingFALSEfor theloadparameter, before you callGetResource. Doing so prevents the Resource Manager from reading the entire resource into memory. Be sure to restore the normal state by callingSetResLoadagain, with theloadparameter set toTRUE, immediately after you callGetResource.If you read a partial resource into memory and then change its size, you must use
SetResourceSizeto change the entire resource's size on disk as necessary before you write the partial resource.SPECIAL CONSIDERATIONS
TheWritePartialResourceprocedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector forWritePartialResourceare
Trap macro Selector _ResourceDispatch $7002 RESULT CODES
noErr 0 No error dskFulErr -34 Disk full resourceInMemory -188 Resource already in memory writingPastEnd -189 Writing past end of file inputOutOfBounds -190 Offset or count out of bounds SEE ALSO
To check for errors, call theResErrorfunction as described on page 1-47.For descriptions of the
GetResourceandSetResLoadroutines, see page 1-68 and page 1-74, respectively. TheSetResourceSizeprocedure is described next.