WritePartialResource
WritePartialResource Write part of a resource to disk
#include <Resources.h> Resource Manager
void WritePartialResource(theResource, offset, buffer, count);
Handle theResource ; 4-byte ResType; resource type to get
long offset ; byte offset value
Ptr buffer ; source buffer
long count ; number of bytes in buffer
The WritePartialResource procedure writes part of a resource to disk,
which allows you to work with small portions of large resources. The resource
is specified by the parameter theResource from the offset parameter, which is
in bytes, through the number of bytes given by the value of the count
parameter. The Resource Manager writes to the resource from the buffer
you indicate with the buffer parameter. You are responsible for the memory
management of this buffer. Call the ResError function to check for errors.
If the disk or the file is locked, the ResError function returns the
appropriate file system error. If you try to write past the end of a resource,
the Resource Manager attempts to enlarge the resource. ResError returns
the writingPastEnd result code if the attempt is successful. If it cannot enlarge
the resource, ResError returns the appropriate file system error. If you
pass an invalid value in the offset parameter, ResError returns the
inputOutOfBounds result code.
If the resource is in memory when you call the WritePartialResource
procedure, the Resource Manager tries to write the resource. If the attempt
is successful, ResError returns resourceInMemory and does not update the
copy in memory. You should be aware that in this situation, the copy in
memory is different from the resource on disk. If the attempt to write the
resource to disk is not successful, ResError returns the appropriate error.
When using partial resource routines, you should call the SetResLoad
procedure specifying FALSE for its load parameter before you call the
GetResource function. The SetResLoad procedure prevents the
Resource Manager from reading the entire resource into memory. Be sure
to restore the normal state of the SetResLoad procedure after you call the
GetResource function.
Returns: an Error Code. It will be one of:
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