Important: The information in this document is obsolete and should not be used for new development.
WritePartialResource
You can use theWritePartialResource
procedure 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
TheWritePartialResource
procedure writes the data specified by thebuffer
parameter to the resource subsection identified by thetheResource
,offset
, andcount
parameters. Your application is responsible for the buffer's memory management.If the disk or the file is locked, the
ResError
function 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. TheResError
function returns the result codewritingPastEnd
if the attempt succeeds. If the Resource Manager cannot enlarge the resource,ResError
returns an appropriate File Manager result code. If you pass an invalid value in theoffset
parameter,ResError
returns the result codeinputOutOfBounds
.The
WritePartialResource
procedure 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,ResError
returns 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,ResError
returns an appropriate error.When using partial resource routines, you should call the
SetResLoad
procedure, specifyingFALSE
for theload
parameter, before you callGetResource
. Doing so prevents the Resource Manager from reading the entire resource into memory. Be sure to restore the normal state by callingSetResLoad
again, with theload
parameter set toTRUE
, immediately after you callGetResource
.If you read a partial resource into memory and then change its size, you must use
SetResourceSize
to change the entire resource's size on disk as necessary before you write the partial resource.SPECIAL CONSIDERATIONS
TheWritePartialResource
procedure 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 forWritePartialResource
are
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 theResError
function as described on page 1-47.For descriptions of the
GetResource
andSetResLoad
routines, see page 1-68 and page 1-74, respectively. TheSetResourceSize
procedure is described next.