Created
January 12, 2010 18:59
-
-
Save iluvcapra/275485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSData *)dataFromResource:(OSType)ident | |
resID:(NSInteger)idnum | |
inFile:(NSString *)path { | |
FSRef feRef; | |
FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &feRef, NULL); | |
ResFileRefNum refFileNum = FSOpenResFile(&feRef, fsRdPerm); | |
UseResFile(refFileNum); | |
Handle resHandle = Get1Resource(ident, idnum); | |
long size = GetResourceSizeOnDisk(resHandle); | |
NSData *retVal = nil; | |
if (size > 0) { | |
retVal = [NSData dataWithBytes:*resHandle length:size]; | |
} | |
CloseResFile(refFileNum); | |
return retVal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment