static CFBundleRef _glitz_agl_get_bundle (const char *name) { CFBundleRef bundle = 0; FSRefParam ref_param; char framework_name[256]; framework_name[0] = strlen (name); strcpy (&framework_name[1], name); memset (&ref_param, 0, sizeof (ref_param)); if (FindFolder (kSystemDomain, kFrameworksFolderType, kDontCreateFolder, &ref_param.ioVRefNum, &ref_param.ioDirID) == noErr) { FSRef ref; memset (&ref, 0, sizeof (ref)); ref_param.ioNamePtr = (unsigned char *) framework_name; ref_param.newRef = &ref; if (PBMakeFSRefSync (&ref_param) == noErr) { CFURLRef url; url = CFURLCreateFromFSRef (kCFAllocatorDefault, &ref); if (url) { bundle = CFBundleCreate (kCFAllocatorDefault, url); CFRelease (url); if (!CFBundleLoadExecutable (bundle)) { CFRelease (bundle); return (CFBundleRef) 0; } } } } return bundle; }
OSErr FSMakeFSRef( FSVolumeRefNum volRefNum, SInt32 dirID, ConstStr255Param name, FSRef *ref) { OSErr result; FSRefParam pb; pb.ioVRefNum = volRefNum; pb.ioDirID = dirID; pb.ioNamePtr = (StringPtr)name; pb.newRef = ref; #if __LP64__ result = PBMakeFSRefUnicodeSync(&pb); #else result = PBMakeFSRefSync(&pb); #endif // __LP64__ return ( result ); }
static void resolveLongName(short vRefNum, long parID,unsigned char*shortFileName,FSSpec *possibleSpec,Boolean isFolder,Str255 *name,squeakFileOffsetType *sizeOfFile) { #if TARGET_API_MAC_CARBON if ((Ptr) PBGetCatalogInfoSync != (Ptr)kUnresolvedCFragSymbolAddress) { FSRefParam FSRefData; FSRef theFSRef; FSCatalogInfo theCatalogInfo; HFSUniStr255 unicodeName; OSErr err; if (possibleSpec == nil) { FSRefParam FSParam; FSParam.ioNamePtr = shortFileName; FSParam.ioVRefNum = vRefNum; FSParam.ioDirID = parID; FSParam.newRef = &theFSRef; FSParam.ioCompletion = null; err = PBMakeFSRefSync(&FSParam); if (err != noErr) goto done1; } else { err = FSpMakeFSRef(possibleSpec,&theFSRef); if (err != noErr) goto done1; } FSRefData.ref = &theFSRef; FSRefData.whichInfo = kFSCatInfoDataSizes; FSRefData.catInfo = &theCatalogInfo; FSRefData.spec = nil; FSRefData.parentRef = nil; FSRefData.outName = &unicodeName; if (PBGetCatalogInfoSync(&FSRefData) == noErr) { CFStringRef theString; if (isFolder) *sizeOfFile = 0; else *sizeOfFile = theCatalogInfo.dataLogicalSize; theString = CFStringCreateWithCharacters (kCFAllocatorDefault, unicodeName.unicode, (CFIndex) unicodeName.length); CFMutableStringRef mStr= CFStringCreateMutableCopy(NULL, 0, theString); CFRelease(theString); // HFS+ imposes Unicode2.1 decomposed UTF-8 encoding on all path elements if (gCurrentVMEncoding == kCFStringEncodingUTF8) CFStringNormalize(mStr, kCFStringNormalizationFormKC); // canonical decomposition CFStringGetPascalString(mStr, (unsigned char *) name,256, gCurrentVMEncoding); CFRelease(mStr); return; } } done1: memcpy(name,shortFileName,sizeof(StrFileName)); #else if (shortFileName == nil) memcpy(name,possibleSpec->name,sizeof(StrFileName)); else memcpy(name,shortFileName,sizeof(StrFileName)); #endif }
memset(&fileRefParam, 0, sizeof(fileRefParam)); memset(&fileRef, 0, sizeof(fileRef)); fileRefParam.ioNamePtr = frameworkName; fileRefParam.newRef = &fileRef; // Frameworks directory/folder err = FindFolder (kSystemDomain, kFrameworksFolderType, false, &fileRefParam.ioVRefNum, (SInt32*)&fileRefParam.ioDirID); if (noErr != err) { DebugStr ("\pCould not find frameworks folder"); return err; } err = PBMakeFSRefSync (&fileRefParam); // make FSRef for folder if (noErr != err) { DebugStr ("\pCould make FSref to frameworks folder"); return err; } // create URL to folder bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef); if (!bundleURLOpenGL) { DebugStr ("\pCould create OpenGL Framework bundle URL"); return paramErr; }