version 2003
PA_GetResourceSize (resFile; kind; resID) long
Parameter | Type | Description | |
resFile | short | File reference number of the file to access | |
kind | unsigned long | Kind (4 Bytes type) of resource to access | |
resID | short | Unique resource ID | |
Function result | long | Size of the resource in bytes |
Description
The routine PA_GetResourceSize returns the size of the resource of type kind in bytes and the unique ID resID in the file referenced by resFile.
If the resource does not exist or if resFile is an invalid file reference number, the routine returns 0 (zero), and PA_GetLastError returns -5 ("Resource not found").
This routine can be useful in pre-allocating buffers before loading the resource into memory.
Example
Loading a resource in a buffer.
char *MyGetResource(short resFile, unsigned long kind, short ID) { char *resData; long size = PA_GetResourceSize(resFile, kind, ID); if( long && (PA_GetLastError() == eER_NoErr ) { resData = malloc(size); size = PA_GetResource(resFile, kind, ID, resData); } return resData; // Use PA_GetLastError() in the calling routine }
See Also
Error Handling
Use PA_GetLastError to see if an error occurred