Esempio n. 1
0
CFBundleRef LoadBundle(const char *tpath)
{
	OSErr theErr;
	CFBundleRef theBundle = NULL;
	FSSpec fspec;
	if ((theErr = MCS_path2FSSpec(tpath, &fspec)) != noErr)
		return NULL;
	FSRef theRef;
	CFURLRef theBundleURL;
	theErr = FSpMakeFSRef(&fspec, &theRef);
	theBundleURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &theRef);
	if (theBundleURL != NULL)
	{
		/* Turn the CFURL into a bundle reference */
		theBundle = CFBundleCreate(kCFAllocatorSystemDefault, theBundleURL);
		CFRelease(theBundleURL);
	}
	if (theErr != noErr || theBundle == NULL)
		return NULL;
	Boolean isLoaded = CFBundleLoadExecutable(theBundle);
	if (!isLoaded)
	{
		CFRelease(theBundle);
		return NULL;
	}
	return theBundle;
}
Esempio n. 2
0
void *file_list1st(const char *dir, FLINFO *fli) {

	FLISTH		ret;
	Str255		fname;
	FSSpec		fss;
	FSRef		fsr;
	FSIterator	fsi;

	mkstr255(fname, dir);
	if ((FSMakeFSSpec(0, 0, fname, &fss) != noErr) ||
		(FSpMakeFSRef(&fss, &fsr) != noErr) ||
		(FSOpenIterator(&fsr, kFSIterateFlat, &fsi) != noErr)) {
		goto ff1_err1;
	}
	ret = _MALLOC(sizeof(_FLHDL), dir);
	if (ret == NULL) {
		goto ff1_err2;
	}
	((FLHDL)ret)->eoff = FALSE;
	((FLHDL)ret)->fsi = fsi;
	if (file_listnext(ret, fli) == SUCCESS) {
		return(ret);
	}

ff1_err2:
	FSCloseIterator(fsi);

ff1_err1:
	return(NULL);
}
Esempio n. 3
0
void	FSSpecToFullPath(const FSSpec &fss, char *path)
{
	FSRef ref;
	
	RequireNoErrString(FSpMakeFSRef(&fss, &ref), "FSpMakeFSRef failed");
	RequireNoErrString(FSRefMakePath(&ref, (UInt8 *)path, 256), "FSRefMakePath failed");
}
Esempio n. 4
0
File: ftmac.c Progetto: 32767/libgdx
  /* Mac OS X 10.5 and later.                                  */
  static OSStatus
  FT_ATSFontGetFileReference( ATSFontRef  ats_font_id,
                              FSRef*      ats_font_ref )
  {
#if defined( MAC_OS_X_VERSION_10_5 ) && \
    ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
 
    OSStatus  err;

    err = ATSFontGetFileReference( ats_font_id, ats_font_ref );

    return err;
#elif __LP64__ /* No 64bit Carbon API on legacy platforms */
    FT_UNUSED( ats_font_id );
    FT_UNUSED( ats_font_ref );


    return fnfErr;
#else /* 32bit Carbon API on legacy platforms */
    OSStatus  err;
    FSSpec    spec;


    err = ATSFontGetFileSpecification( ats_font_id, &spec );
    if ( noErr == err )
      err = FSpMakeFSRef( &spec, ats_font_ref );

    return err;
#endif
  }
 string& Configuration::GetExecutablePath() {
     string& path = new string("");
     ProcessSerialNumber PSN;
     ProcessInfoRec pinfo;
     FSSpec pspec;
     FSRef fsr;
     OSStatus err;
     // set up process serial number.
     PSN.highLongOfPSN = 0;
     PSN.lowLongOfPSN = kCurrentProcess;
     // set up info block.
     pinfo.processInfoLength = sizeof(pinfo);
     pinfo.processName = NULL;
     pinfo.processAppSpec = &pspec;
     // grab the vrefnum and directory.
     err = GetProcessInformation(&PSN, &pinfo);
     if (! err ) {
         char c_path[2048];
         FSSpec fss2;
         int tocopy;
         err = FSMakeFSSpec(pspec.vRefNum, pspec.parID, 0, &fss2);
         if ( ! err ) {
             err = FSpMakeFSRef(&fss2, &fsr);
             if ( ! err ) {
                 char c_path[2049];
                 err = (OSErr)FSRefMakePath(&fsr, (UInt8*)c_path, 2048);
                 if (! err ) {
                     path += c_path;
                 }
             }
         }
     }
     return path;
 }
Esempio n. 6
0
short file_attr(const char *path) {

	Str255			fname;
	FSSpec			fss;
	FSRef			fsr;
	FSCatalogInfo	fsci;
	short			ret;

	mkstr255(fname, path);
	if ((FSMakeFSSpec(0, 0, fname, &fss) != noErr) ||
		(FSpMakeFSRef(&fss, &fsr) != noErr) ||
		(FSGetCatalogInfo(&fsr, kFSCatInfoNodeFlags, &fsci,
										NULL, NULL, NULL) != noErr)) {
		return(-1);
	}
	if (fsci.nodeFlags & kFSNodeIsDirectoryMask) {
		ret = FILEATTR_DIRECTORY;
	}
	else {
		ret = FILEATTR_ARCHIVE;
	}
	if (fsci.nodeFlags & kFSNodeLockedMask) {
		ret |= FILEATTR_READONLY;
	}
	return(ret);
}
Esempio n. 7
0
ComponentResult FFAvi_MovieImportFile(ff_global_ptr storage, const FSSpec *theFile, Movie theMovie, Track targetTrack,
									  Track *usedTrack, TimeValue atTime, TimeValue *addedDuration, long inFlags, long *outFlags)
{
	ComponentResult result;
	Handle dataRef = NULL;
	OSType dataRefType;
	FSRef theFileFSRef;
	
	*outFlags = 0;
	
	result = QTNewDataReferenceFromFSSpec(theFile, 0, &dataRef, &dataRefType);
	require_noerr(result,bail);
	
	result = MovieImportDataRef(storage->ci, dataRef, dataRefType, theMovie, targetTrack, usedTrack, atTime, addedDuration,
								inFlags, outFlags);
	require_noerr(result, bail);
	
	result = FSpMakeFSRef(theFile, &theFileFSRef);
	require_noerr(result, bail);
		
bail:
		if(dataRef)
			DisposeHandle(dataRef);
	
	return result;
} /* FFAvi_MovieImportFile() */
Esempio n. 8
0
  FT_New_Face_From_FSSpec( FT_Library     library,
                           const FSSpec*  spec,
                           FT_Long        face_index,
                           FT_Face*       aface )
  {
#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
      ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
    FT_UNUSED( library );
    FT_UNUSED( spec );
    FT_UNUSED( face_index );
    FT_UNUSED( aface );

    return FT_THROW( Unimplemented_Feature );
#else
    FSRef  ref;


    /* check of `library' and `aface' delayed to `FT_New_Face_From_FSRef' */

    if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
      return FT_THROW( Invalid_Argument );
    else
      return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
#endif
  }
Esempio n. 9
0
/* This function extracts a single FSRef from a NavReplyRecord. */
static OSErr ExtractSingleItem(const NavReplyRecord *reply, FSRef *item)
{
    FSSpec fss;
    SInt32 itemCount;
    DescType junkType;
    AEKeyword junkKeyword;
    Size junkSize;
    OSErr osErr;

    osErr = AECountItems(&reply->selection, &itemCount);
    if( itemCount != 1 )	/* we only work with one object at a time */
        osErr = paramErr;
    if( osErr == noErr )
        osErr = AEGetNthPtr(&reply->selection, 1, typeFSS, &junkKeyword, &junkType, &fss, sizeof(fss), &junkSize);
    if( osErr == noErr )
    {
        mycheck(junkType == typeFSS);
        mycheck(junkSize == sizeof(FSSpec));

        /* We call FSMakeFSSpec because sometimes Nav is braindead		*/
        /* and gives us an invalid FSSpec (where the name is empty).	*/
        /* While FSpMakeFSRef seems to handle that (and the file system	*/
        /* engineers assure me that that will keep working (at least	*/
        /* on traditional Mac OS) because of the potential for breaking	*/
        /* existing applications), I'm still wary of doing this so		*/
        /* I regularise the FSSpec by feeding it through FSMakeFSSpec.	*/

        if( fss.name[0] == 0 )
            osErr = FSMakeFSSpec(fss.vRefNum, fss.parID, fss.name, &fss);
        if( osErr == noErr )
            osErr = FSpMakeFSRef(&fss, item);
    }

    return osErr;
}
Esempio n. 10
0
static OSStatus strcpyFileSystemRepresentationFromClassicPath(char *nativePath, char * classicPath, long nativePathMaxLength )
{
		CFURLRef   fileAsCFURLRef = 0;
		Boolean    resolveAgainstBase = true;
		FSRef fileAsFSRef;
		Boolean gotPath;
		char pathPStr[256];
		FSSpec spec;
		OSStatus err = 0;
		
		strcpy(pathPStr,classicPath);
		my_c2pstr(pathPStr);
		err = FSMakeFSSpec(0, 0, (StringPtr)pathPStr,&spec);
		if(err == fnfErr) {
			// just means the file does not exist yet
			err = FSpCreate (&spec,'MPW ','TEXT',smSystemScript); // we should be able to use any creator and type here
		}
		if(err) return err;
		
		err = FSpMakeFSRef(&spec,&fileAsFSRef);
		if(err) return err;

		 // Convert the reference to the file to a CFURL
		fileAsCFURLRef = CFURLCreateFromFSRef(NULL, &fileAsFSRef);
		if(fileAsCFURLRef) {
			gotPath = CFURLGetFileSystemRepresentation(fileAsCFURLRef,resolveAgainstBase,(UInt8 *)nativePath,nativePathMaxLength);
			CFRelease(fileAsCFURLRef); fileAsCFURLRef = 0;
		}
		
		if(gotPath) 
			return noErr;
		
		return -1; // did not get the path

}
Esempio n. 11
0
static OSStatus spec2path(const FSSpec& spec, char* path, UInt32 maxPathSize)
{
    FSRef ref;
    OSStatus status = FSpMakeFSRef(&spec, &ref);
    if (status == noErr)
        status = ref2path(ref, path, maxPathSize);
    return status;
}
Esempio n. 12
0
short file_attr(const char *path) {

#ifdef TARGET_API_MAC_CARBON
	Str255			fname;
	FSSpec			fss;
	FSRef			fsr;
	FSCatalogInfo	fsci;
	short			ret;

	mkstr255(fname, path);
	if ((FSMakeFSSpec(0, 0, fname, &fss) != noErr) ||
		(FSpMakeFSRef(&fss, &fsr) != noErr) ||
		(FSGetCatalogInfo(&fsr, kFSCatInfoNodeFlags, &fsci,
										NULL, NULL, NULL) != noErr)) {
		return(-1);
	}
	if (fsci.nodeFlags & kFSNodeIsDirectoryMask) {
		ret = FILEATTR_DIRECTORY;
	}
	else {
		ret = FILEATTR_ARCHIVE;
	}
	if (fsci.nodeFlags & kFSNodeLockedMask) {
		ret |= FILEATTR_READONLY;
	}
	return(ret);
#else
	Str255		fname;
	FSSpec		fss;
	CInfoPBRec	pb;
	short		ret;

	mkstr255(fname, path);
	FSMakeFSSpec(0, 0, fname, &fss);
	pb.dirInfo.ioNamePtr = fss.name;
	pb.dirInfo.ioVRefNum = fss.vRefNum;
	pb.dirInfo.ioDrDirID = fss.parID;
	if (fss.name[0] == 0) {
		pb.dirInfo.ioFDirIndex = -1;
	}
	else {
		pb.dirInfo.ioFDirIndex = 0;
	}
	if (PBGetCatInfo(&pb, false) != noErr) {
		return(-1);
	}
	if (pb.hFileInfo.ioFlAttrib & ioDirMask) {
		ret = FILEATTR_DIRECTORY;
	}
	else {
		ret = FILEATTR_ARCHIVE;
	}
	if (pb.hFileInfo.ioFlAttrib & 0x01) {
		ret |= FILEATTR_READONLY;
	}
	return(ret);
#endif
}
Esempio n. 13
0
/* FSSpec -> FSRef -> URL(Unix) -> HPFS+ */
int PathToFile(char *pathName, int pathNameMax, FSSpec *where,UInt32 encoding) {        
        CFURLRef sillyThing;
        CFStringRef filePath;
        FSSpec	failureRetry;
        FSRef	theFSRef;
        OSErr	error;
        Boolean isDirectory=false,retryWithDirectory=false;
        char	rememberName[256];
        
        *pathName = 0x00;
        error = FSpMakeFSRef (where, &theFSRef);
        if (error != noErr) {
            retryWithDirectory = true;
            failureRetry = *where;
            CopyCStringToPascal(":",failureRetry.name);
            CopyPascalStringToC(where->name,(char *) &rememberName);
            error = FSpMakeFSRef(&failureRetry,&theFSRef);
            if (error != noErr) 
                return -1;
	}
        
        sillyThing =  CFURLCreateFromFSRef (kCFAllocatorDefault, &theFSRef);
        isDirectory = CFURLHasDirectoryPath(sillyThing);
        
        filePath = CFURLCopyFileSystemPath (sillyThing, kCFURLHFSPathStyle);
        CFRelease(sillyThing);
        
  		CFMutableStringRef mutableStr= CFStringCreateMutableCopy(NULL, 0, filePath);
          CFRelease(filePath);
  
  		// HFS+ imposes Unicode2.1 decomposed UTF-8 encoding on all path elements
  		if (gCurrentVMEncoding == kCFStringEncodingUTF8) 
  			CFStringNormalize(mutableStr, kCFStringNormalizationFormKC); // pre-combined
  
          CFStringGetCString (mutableStr, pathName,pathNameMax, encoding);
        
        if (retryWithDirectory) {
            strcat(pathName,":");
            strcat(pathName,rememberName);
            isDirectory = false;
        }
        if (isDirectory)
            strcat(pathName,":");
        return 0;
}
Esempio n. 14
0
wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
{
    FSRef fsRef ;
    if ( FSpMakeFSRef( spec , &fsRef) == noErr )
    {
        return wxMacFSRefToPath( &fsRef ) ;
    }
    return wxEmptyString ;
}
Esempio n. 15
0
/* フォルダアイコンをチェック */
OSErr FolderIconCheck(const FSSpec *theFolderSpec,short *alertMode)
{
	OSErr	err;
	long	dirID;
	FSSpec	theIconFile;
	Str15	iconFileName;
	Boolean	isDirectory;
	#ifdef __MOREFILESX__
	FSRef	fsRef;
	FinderInfo	info;
	
	err = FSpMakeFSRef(theFolderSpec,&fsRef);
	if (err != noErr) return err;
	#else
	DInfo	dirInfo;
	#endif
	
	/* まず、カスタムアイコンフラグが立っているかどうかを調べる */
	/* ここでエラーが発生する場合はおそらくフォルダアイコン編集も不可能なのでそのまま返る */
	#ifdef __MOREFILESX__
	err = FSGetFinderInfo(&fsRef,&info,NULL,NULL);
	#else
	err=FSpGetDInfo(theFolderSpec,&dirInfo);
	#endif
	if (err!=noErr) return err;
	
	/* カスタムアイコンフラグが立っていなければ問題なし */
	#ifdef __MOREFILESX__
	if ((info.folder.finderFlags & kHasCustomIcon) == 0) return noErr;
	#else
	if ((dirInfo.frFlags & kHasCustomIcon) == 0) return noErr;
	#endif
	
	/* 立っている場合は、カスタムアイコンをチェック */
	#ifdef __MOREFILESX__
	err = FSGetNodeID(&fsRef,&dirID,&isDirectory);
	#else
	err=FSpGetDirectoryID(theFolderSpec,&dirID,&isDirectory);
	#endif
	if (err!=noErr) return err;
	
	GetIndString(iconFileName,140,3);
	err=FSMakeFSSpec(theFolderSpec->vRefNum,dirID,iconFileName,&theIconFile);
	if (err==fnfErr) /* アイコンファイルが見つからない場合は、フラグが間違っているわけだから修正 */
	{
		#ifdef __MOREFILESX__
		err = FSClearHasCustomIcon(&fsRef);
		#else
		err=FSpClearHasCustomIcon(theFolderSpec);
		#endif
		return noErr;
	}
	else if (err!=noErr) /* それ以外のエラーなら編集できないだろうから戻る */
		return err;
	
	return FileIconCheck(&theIconFile,alertMode);
}
Esempio n. 16
0
  FT_New_Face_From_FSSpec( FT_Library     library,
                           const FSSpec*  spec,
                           FT_Long        face_index,
                           FT_Face*       aface )
  {

#if HAVE_FSREF

    FSRef  ref;


    if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
      return FT_THROW( Invalid_Argument );
    else
      return FT_New_Face_From_FSRef( library, &ref, face_index, aface );

#elif HAVE_FSSPEC

    FT_Error      error;
    FT_Open_Args  args;
    OSErr         err;
    UInt8         pathname[PATH_MAX];


    if ( !spec )
      return FT_THROW( Invalid_Argument );

    err = FT_FSpMakePath( spec, pathname, sizeof ( pathname ) );
    if ( err )
      error = FT_ERR( Cannot_Open_Resource );

    error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
    if ( error || *aface )
      return error;

    /* fallback to datafork font */
    args.flags    = FT_OPEN_PATHNAME;
    args.pathname = (char*)pathname;
    return FT_Open_Face( library, &args, face_index, aface );

#else

    FT_UNUSED( library );
    FT_UNUSED( spec );
    FT_UNUSED( face_index );
    FT_UNUSED( aface );

    return FT_THROW( Unimplemented_Feature );

#endif /* HAVE_FSREF, HAVE_FSSPEC */

  }
Esempio n. 17
0
MADErr MADMusicIdentifyFSpFile(MADLibrary *lib, char *type, FSSpecPtr theSpec)
{
#ifdef __LP64__
	return MADOrderNotImplemented;
#else
	FSRef tempRef;
	if (theSpec == NULL)
		return MADParametersErr;
	
	FSpMakeFSRef(theSpec, &tempRef);
	return MADMusicIdentifyFSRef(lib, type, &tempRef);
#endif
}
Esempio n. 18
0
pascal OSStatus MoreAEOCreateObjSpecifierFromFSSpec(const FSSpecPtr pFSSpecPtr, AEDesc *pObjSpecifier){
	OSErr anErr = paramErr;

	if (nil != pFSSpecPtr) {
		FSRef tFSRef;

		anErr = FSpMakeFSRef(pFSSpecPtr, &tFSRef);
		if (noErr == anErr) {
			anErr = MoreAEOCreateObjSpecifierFromFSRef(&tFSRef, pObjSpecifier);
		}
	}
	return anErr;
}
Esempio n. 19
0
MADErr MADLoadMusicFSpFile(MADLibrary *lib, MADMusic **music, char *plugType, FSSpecPtr theSpec)
{
#ifdef __LP64__
	return MADOrderNotImplemented;
#else
	FSRef tempRef;
	if (theSpec == NULL)
		return MADParametersErr;
	
	FSpMakeFSRef(theSpec, &tempRef);
	return MADLoadMusicFSRef(lib, music, plugType, &tempRef);
#endif
}
Esempio n. 20
0
Boolean MRJSession::addToClassPath(const FSSpec& fileSpec)
{
    // if the Java VM has started already, it's too late to do this (for now).
    if (mJavaVM)
        return false;

    // keep accumulating paths.
    FSRef ref;
    OSStatus status = FSpMakeFSRef(&fileSpec, &ref);
    if (status == noErr)
        mClassPath.push_back(ref);

    return true;
}
Esempio n. 21
0
  /* Apple will provide one eventually.                        */
  static OSStatus
  FT_ATSFontGetFileReference( ATSFontRef  ats_font_id,
                              FSRef*      ats_font_ref )
  {
    OSStatus  err;
    FSSpec    spec;


    err = ATSFontGetFileSpecification( ats_font_id, &spec );
    if ( noErr == err )
      err = FSpMakeFSRef( &spec, ats_font_ref );

    return err;
  }
Esempio n. 22
0
/////////////////////////////////////////////////////////////
// Get a pointer to an OpenGL extension
// Note on the Mac, this does a lot of work that could be saved
// if you call this function repeatedly. Write your own function that
// gets the bundle once, gets all the function pointers, then releases
// the bundle.
void *gltGetExtensionPointer(const char *szExtensionName)
	{
#ifdef WIN32
    // Well, this one is simple. An OpenGL context must be
    // current first. Returns NULL if extension not supported
    return (void *)wglGetProcAddress(szExtensionName);
#endif
	
#ifdef linux
    // Pretty much ditto above
    return (void *)glXGetProcAddress(szExtensionName);
#endif

    
#ifdef __APPLE__
    // Mac is a bit more tricky.
    // First we need the bundle
    CFBundleRef openGL = 0;
    SInt16      fwVersion = 0;
    SInt32      fwDir = 0;
    
    if(FindFolder(kSystemDomain, kFrameworksFolderType, kDontCreateFolder, &fwVersion, &fwDir) != noErr)
        return NULL;
	
    FSSpec fSpec;
    FSRef  fRef;
    if(FSMakeFSSpec(fwVersion, fwDir, "\pOpenGL.framework", &fSpec) != noErr)
        return NULL;
	
    FSpMakeFSRef(&fSpec, &fRef);
    CFURLRef url = CFURLCreateFromFSRef(kCFAllocatorDefault, &fRef);
    if(!url)
        return NULL;
	
    openGL = CFBundleCreate(kCFAllocatorDefault, url);
    CFRelease(url);
    
    // Then load the function pointer from the bundle
    CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, szExtensionName, kCFStringEncodingMacRoman);
    void *pFunc = CFBundleGetFunctionPointerForName(openGL, string);
    
    // Release the bundle and string
    CFRelease(string);
    CFRelease(openGL);
    
    // Return the function ponter
    return pFunc;
#endif    
    }
OSErr AcroPluginCFragInitFunction( const CFragInitBlock *	initBlock )
{
	OSErr err = __initialize(initBlock);
	
	if (err == noErr)
	{	
#if TARGET_API_MAC_CARBON
		if (initBlock->fragLocator.where == kDataForkCFragLocator)
		{
			// Mac OS X 10.1 and earlier has a bug where packaged CFM libs are still passed 
			// kDataForkCFragLocator instead of kCFBundleCFragLocator. Apple claims this will
			// fixed in Jaguar.
			FSSpec spec = *initBlock->fragLocator.u.onDisk.fileSpec;
			
			// See if parent folder is named "MacOS"
			FSMakeFSSpec(spec.vRefNum, spec.parID, "\p", &spec);
			if (IdenticalString(spec.name, "\pMacOS", NULL) == 0)
			{
				// See if parent folder is named "Contents"
				FSMakeFSSpec(spec.vRefNum, spec.parID, "\p", &spec);
				if (IdenticalString(spec.name, "\pContents", NULL) == 0)
				{
					// Get Bundle Ref
					FSRef fsRef;
					FSMakeFSSpec(spec.vRefNum, spec.parID, "\p", &spec);
					if (noErr == FSpMakeFSRef(&spec, &fsRef))
					{
						CFURLRef cfURL = CFURLCreateFromFSRef(NULL, &fsRef);
						if (cfURL)
						{
							gPluginBundle = CFBundleCreate(NULL, cfURL);
#if DEBUG
							CFShow(cfURL);
							CFShow(gPluginBundle);
#endif
							
							if (gPluginBundle)
								gResFile = CFBundleOpenBundleResourceMap(gPluginBundle);
							
							CFRelease(cfURL);
						}
					}
				}
			}
		}
Esempio n. 24
0
  /* Create a new FT_Face from a file spec to a suitcase file. */
  static FT_Error
  FT_New_Face_From_dfont( FT_Library  library,
                          FSSpec*     spec,
                          FT_Long     face_index,
                          FT_Face*    aface )
  {
    FT_Error  error = FT_Err_Ok;
    short     res_ref, res_index;
    Handle    fond;
    FSRef     hostContainerRef;


    error = FSpMakeFSRef( spec, &hostContainerRef );
    if ( error == noErr )
      error = FSOpenResourceFile( &hostContainerRef,
                                  0, NULL, fsRdPerm, &res_ref );

    if ( error != noErr )
      return FT_Err_Cannot_Open_Resource;

    UseResFile( res_ref );

    /* face_index may be -1, in which case we
       just need to do a sanity check */
    if ( face_index < 0 )
      res_index = 1;
    else
    {
      res_index = (short)( face_index + 1 );
      face_index = 0;
    }
    fond = Get1IndResource( 'FOND', res_index );
    if ( ResError() )
    {
      error = FT_Err_Cannot_Open_Resource;
      goto Error;
    }

    error = FT_New_Face_From_FOND( library, fond, face_index, aface );

  Error:
    CloseResFile( res_ref );
    return error;
  }
Esempio n. 25
0
/* update icons in Finder */
void UpdateFinderIcon(const FSSpec *theFile)
{
	OSErr	err;
	
	/* update icons */
	if (isOSX)
	{
		AppleEvent		aeEvent={typeNull,NULL};
		
		/* send AppleEvnet that class=kAEFinderSuite and id=kAESync to Finder */
		err=MakeUpdateEvent(theFile,&aeEvent);
		if (err!=noErr) return;
		
		err=AESend(&aeEvent,nil,kAENoReply+kAEAlwaysInteract+kAECanSwitchLayer,
				kAENormalPriority,kNoTimeOut,nil,nil);
		
		AEDisposeDesc(&aeEvent);
	}
	else
	{
		if (isIconServicesAvailable)
			FlushIconRefsByVolume(theFile->vRefNum);
		else
		{
			/* change the modification data of the parent folder */
			FSSpec	parentFolder;
			
			err=FSMakeFSSpec(theFile->vRefNum,theFile->parID,NULL,&parentFolder);
			if (err==noErr)
			{
				#ifdef __MOREFILESX__
				FSRef	fsRef;
				
				err = FSpMakeFSRef(&parentFolder,&fsRef);
				err = FSBumpDate(&fsRef);
				
				#else
				err=FSpBumpDate(&parentFolder);
				#endif
			}
		}
	}
}
Esempio n. 26
0
  /* Mac OS X 10.5 and later.                                  */
  static OSStatus
  FT_ATSFontGetFileReference( ATSFontRef  ats_font_id,
                              FSRef*      ats_font_ref )
  {
    OSStatus  err;

#if !defined( MAC_OS_X_VERSION_10_5 ) || \
    MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
    FSSpec    spec;


    err = ATSFontGetFileSpecification( ats_font_id, &spec );
    if ( noErr == err )
      err = FSpMakeFSRef( &spec, ats_font_ref );
#else
    err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
#endif

    return err;
  }
OSErr GHOST_SystemCarbon::sAEHandlerOpenDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
{
	//GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon;
	AEDescList docs;
	SInt32 ndocs;
	OSErr err;

	err = AEGetParamDesc(event, keyDirectObject, typeAEList, &docs);
	if (err != noErr) return err;

	err = AECountItems(&docs, &ndocs);
	if (err == noErr) {
		int i;
	
		for (i = 0; i < ndocs; i++) {
			FSSpec fss;
			AEKeyword kwd;
			DescType actType;
			Size actSize;
		
			err = AEGetNthPtr(&docs, i + 1, typeFSS, &kwd, &actType, &fss, sizeof(fss), &actSize);
			if (err != noErr)
				break;
		
			if (i == 0) {
				FSRef fsref;
				
				if (FSpMakeFSRef(&fss, &fsref) != noErr)
					break;
				if (FSRefMakePath(&fsref, (UInt8 *) g_firstFileBuf, sizeof(g_firstFileBuf)) != noErr)
					break;

				g_hasFirstFile = true;
			}
		}
	}
	
	AEDisposeDesc(&docs);
	
	return err;
}
Esempio n. 28
0
FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
{
	FT_Error err = FT_Err_Cannot_Open_Resource;

	/* Get font reference from name. */
	CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, font_name, kCFStringEncodingUTF8);
	ATSFontRef font = ATSFontFindFromName(name, kATSOptionFlagsDefault);
	CFRelease(name);
	if (font == kInvalidFont) return err;

	/* Get a file system reference for the font. */
	FSRef ref;
	OSStatus os_err = -1;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
	if (MacOSVersionIsAtLeast(10, 5, 0)) {
		os_err = ATSFontGetFileReference(font, &ref);
	} else
#endif
	{
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) && !defined(__LP64__)
		/* This type was introduced with the 10.5 SDK. */
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
	#define ATSFSSpec FSSpec
#endif
		FSSpec spec;
		os_err = ATSFontGetFileSpecification(font, (ATSFSSpec *)&spec);
		if (os_err == noErr) os_err = FSpMakeFSRef(&spec, &ref);
#endif
	}

	if (os_err == noErr) {
		/* Get unix path for file. */
		UInt8 file_path[PATH_MAX];
		if (FSRefMakePath(&ref, file_path, sizeof(file_path)) == noErr) {
			DEBUG(freetype, 3, "Font path for %s: %s", font_name, file_path);
			err = FT_New_Face(_library, (const char *)file_path, 0, face);
		}
	}

	return err;
}
Esempio n. 29
0
//********************************************************************************
// A simple wrapper around CreateObjSpecifier which creates
// an object specifier from a FSSpec using formName.
pascal OSStatus MoreAEOCreateObjSpecifierFromFSSpec(const FSSpecPtr pFSSpecPtr,AEDesc *pObjSpecifier)
{
	OSErr 		anErr = paramErr;

	if (NULL != pFSSpecPtr)
	{
#if TARGET_API_MAC_CARBON
		FSRef tFSRef;

		anErr = FSpMakeFSRef(pFSSpecPtr,&tFSRef);
		if (noErr == anErr)
		{
			anErr = MoreAEOCreateObjSpecifierFromFSRef(&tFSRef,pObjSpecifier);
		}
#else
		AEDesc containerAEDesc = {typeNull,NULL};

		anErr = MoreAEOCreateAliasObjectFromFSSpec(pFSSpecPtr,&containerAEDesc,pObjSpecifier);
#endif TARGET_API_MAC_CARBON
	}
	return anErr;
}//end MoreAEOCreateObjSpecifierFromFSSpec
Esempio n. 30
0
BOOL getLongFileName(char *dst, const char *path) {

	FSSpec			fss;
	Str255			fname;
	FSRef			fref;
	HFSUniStr255	name;

	if (*path == '\0') {
		return(false);
	}
	mkstr255(fname, path);
	FSMakeFSSpec(0, 0, fname, &fss);
	FSpMakeFSRef(&fss, &fref);
	if (FSGetCatalogInfo(&fref, kFSCatInfoNone, NULL, &name, NULL, NULL)
																!= noErr) {
		return(false);
	}
	char2str(dst, 512, name.unicode, name.length);
	if (!dst) {
		return(false);
	}
	return(true);
}