5 // Created by Joseph Spiros on Thu Dec 25 2003.
6 // Copyright (c) 2003 __MyCompanyName__. All rights reserved.
9 #import "ITMacResourceFile.h"
12 @implementation ITMacResourceFile
14 - (id)initWithContentsOfFile:(NSString *)path {
15 HFSUniStr255 dataForkName;
16 FSGetDataForkName(&dataForkName);
17 return [self initWithContentsOfFile:path fork:dataForkName];
20 - (id)initWithContentsOfFile:(NSString *)path fork:(HFSUniStr255)namedFork {
21 if (self = [super init]) {
22 if (FSPathMakeRef([path fileSystemRepresentation],&_fileReference,NULL) == noErr) {
23 FSOpenResourceFile(&_fileReference, namedFork.length, namedFork.unicode, fsRdPerm, &_referenceNumber);
31 - (ITMacResource *)resourceOfType:(ITMacResourceType)type withID:(NSNumber *)idNum {
32 return [[ITMacResource _classForType:type] _resourceWithHandle:GetResource((ResType)type,[idNum shortValue])];
35 - (ITMacResource *)resourceOfType:(ITMacResourceType)type withName:(NSString *)name {
37 StringPtr _ptr = CFStringGetPascalStringPtr((CFStringRef)name, kCFStringEncodingMacRomanLatin1);
39 if (CFStringGetPascalString((CFStringRef)name, _buffer, 256, kCFStringEncodingMacRomanLatin1)) {
45 return [[ITMacResource _classForType:type] _resourceWithHandle:GetNamedResource((ResType)type,_ptr)];
49 CloseResFile(_referenceNumber);