当前位置: 首页>>代码示例>>C++>>正文


C++ UseResFile函数代码示例

本文整理汇总了C++中UseResFile函数的典型用法代码示例。如果您正苦于以下问题:C++ UseResFile函数的具体用法?C++ UseResFile怎么用?C++ UseResFile使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了UseResFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mCurResFile

StAcroResourceContext::StAcroResourceContext(short resFile)
	: mCurResFile(resFile)
{
#if TARGET_API_MAC_CARBON
	mOldResFile = CurResFile();

	if( mCurResFile )
		UseResFile(mCurResFile);
			
#else

	mOldResFile = PreCarbonSetupResourceChain( );
	
#endif
}
开发者ID:Ulysses1962,项目名称:light-imposition,代码行数:15,代码来源:SafeResources.cpp

示例2: FT_New_Face_From_dfont

  /* 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;
  }
开发者ID:dikerex,项目名称:theqvd,代码行数:45,代码来源:ftmac.c

示例3: FT_New_Face_From_Suitcase

  /* Create a new FT_Face from a file spec to a suitcase file. */
  static FT_Error
  FT_New_Face_From_Suitcase( FT_Library    library,
                             const UInt8*  pathname,
                             FT_Long       face_index,
                             FT_Face*      aface )
  {
    FT_Error       error = FT_ERR( Cannot_Open_Resource );
    ResFileRefNum  res_ref;
    ResourceIndex  res_index;
    Handle         fond;
    short          num_faces_in_res;


    if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
      return FT_THROW( Cannot_Open_Resource );

    UseResFile( res_ref );
    if ( ResError() )
      return FT_THROW( Cannot_Open_Resource );

    num_faces_in_res = 0;
    for ( res_index = 1; ; ++res_index )
    {
      short  num_faces_in_fond;


      fond = Get1IndResource( TTAG_FOND, res_index );
      if ( ResError() )
        break;

      num_faces_in_fond  = count_faces( fond, pathname );
      num_faces_in_res  += num_faces_in_fond;

      if ( 0 <= face_index && face_index < num_faces_in_fond && error )
        error = FT_New_Face_From_FOND( library, fond, face_index, aface );

      face_index -= num_faces_in_fond;
    }

    CloseResFile( res_ref );
    if ( !error && aface )
      (*aface)->num_faces = num_faces_in_res;
    return error;
  }
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:45,代码来源:ftmac.c

示例4: CallImportPlug

OSErr CallImportPlug( 		MADLibrary		*inMADDriver,
													short					PlugNo,			// CODE du plug
													OSType				order,
													char					*AlienFile,
													MADMusic			*theNewMAD,
													PPInfoRec			*info)
{
	OSErr					myErr;
	short					fileID = 0;
	MADDriverSettings		driverSettings;
	CFragConnectionID		connID;
	Ptr						mainAddr;
	Str255					errName;
	static OSErr			(*mainPLUG)( OSType, char*, MADMusic*, PPInfoRec*, MADDriverSettings *);

	driverSettings.sysMemory = false;

	if( !EqualString( RSRCNAME, inMADDriver->ThePlug[ PlugNo].file.name, false, false))
	{
		fileID = FSpOpenResFile( &inMADDriver->ThePlug[ PlugNo].file, fsCurPerm);
		UseResFile( fileID);
	}
	
	myErr = GetDiskFragment( &inMADDriver->ThePlug[ PlugNo].file, 0, kCFragGoesToEOF, inMADDriver->ThePlug[ PlugNo].file.name, kLoadCFrag, &connID, (Ptr *) &mainPLUG, errName);

	if( myErr == noErr)
	{
		myErr = mainPLUG ( order, AlienFile, theNewMAD, info, &driverSettings);
		
//			DisposePtr( (Ptr) mainPLUG);
		
		CloseConnection( &connID);
	}

//	myErr = TESTmain( order, AlienFile, theNewMAD, info, &driverSettings);
	
	if( !EqualString( RSRCNAME, inMADDriver->ThePlug[ PlugNo].file.name, false, false))
		CloseResFile( fileID);
	
//	theNewMAD->currentDriver = NULL;
	
	return( myErr);
}
开发者ID:mctully,项目名称:tntbasic,代码行数:43,代码来源:Mac-PlugImport.c

示例5: PyMac_PRECHECK

static PyObject *Res_UseResFile(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    short refNum;
#ifndef UseResFile
    PyMac_PRECHECK(UseResFile);
#endif
    if (!PyArg_ParseTuple(_args, "h",
                          &refNum))
        return NULL;
    UseResFile(refNum);
    {
        OSErr _err = ResError();
        if (_err != noErr) return PyMac_Error(_err);
    }
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}
开发者ID:0xcc,项目名称:python-read,代码行数:19,代码来源:_Resmodule.c

示例6: read_setting_i

int read_setting_i(void *handle, char const *key, int defvalue) {
    int fd;
    Handle h;
    int value;
    Str255 pkey;

    if (handle == NULL) goto out;
    fd = *(int *)handle;
    UseResFile(fd);
    if (ResError() != noErr) goto out;
    c2pstrcpy(pkey, key);
    h = Get1NamedResource(FOUR_CHAR_CODE('Int '), pkey);
    if (h == NULL) goto out;
    value = *(int *)*h;
    ReleaseResource(h);
    if (ResError() != noErr) goto out;
    return value;

  out:
    return defvalue;
}
开发者ID:sdottaka,项目名称:cvsnt-sjis,代码行数:21,代码来源:macstore.c

示例7: FT_New_Face_From_Suitcase

  /* Create a new FT_Face from a file spec to a suitcase file. */
  static FT_Error
  FT_New_Face_From_Suitcase( FT_Library    library,
                             const UInt8*  pathname,
                             FT_Long       face_index,
                             FT_Face*      aface )
  {
    FT_Error  error = FT_Err_Cannot_Open_Resource;
    short     res_ref, res_index;
    Handle    fond;
    short     num_faces_in_res, num_faces_in_fond;


    if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
      return FT_Err_Cannot_Open_Resource;

    UseResFile( res_ref );
    if ( ResError() )
      return FT_Err_Cannot_Open_Resource;

    num_faces_in_res = 0;
    for ( res_index = 1; ; ++res_index )
    {
      fond = Get1IndResource( 'FOND', res_index );
      if ( ResError() )
        break;

      num_faces_in_fond  = count_faces( fond, pathname );
      num_faces_in_res  += num_faces_in_fond;

      if ( 0 <= face_index && face_index < num_faces_in_fond && error )
        error = FT_New_Face_From_FOND( library, fond, face_index, aface );

      face_index -= num_faces_in_fond;
    }

    CloseResFile( res_ref );
    if ( FT_Err_Ok == error && NULL != aface )
      (*aface)->num_faces = num_faces_in_res;
    return error;
  }
开发者ID:gorlak,项目名称:panda3d-thirdparty,代码行数:41,代码来源:ftmac.c

示例8: read_setting_filename

int read_setting_filename(void *handle, const char *key, Filename *result)
{
    int fd;
    AliasHandle h;
    Boolean changed;
    OSErr err;
    Str255 pkey;

    if (handle == NULL) goto out;
    fd = *(int *)handle;
    UseResFile(fd);
    if (ResError() != noErr) goto out;
    c2pstrcpy(pkey, key);
    h = (AliasHandle)Get1NamedResource(rAliasType, pkey);
    if (h == NULL) goto out;
    if ((*h)->userType == 'pTTY' && (*h)->aliasSize == sizeof(**h))
	memset(result, 0, sizeof(*result));
    else {
	err = ResolveAlias(NULL, h, &result->fss, &changed);
	if (err != noErr && err != fnfErr) goto out;
	if ((*h)->userType == 'pTTY') {
	    long dirid;
	    StrFileName fname;

	    /* Tail of record is pascal string contaning leafname */
	    if (FSpGetDirID(&result->fss, &dirid, FALSE) != noErr) goto out;
	    memcpy(fname, (char *)*h + (*h)->aliasSize,
		   GetHandleSize((Handle)h) - (*h)->aliasSize);
	    err = FSMakeFSSpec(result->fss.vRefNum, dirid, fname,
			       &result->fss);
	    if (err != noErr && err != fnfErr) goto out;
	}
    }
    ReleaseResource((Handle)h);
    if (ResError() != noErr) goto out;
    return 1;

  out:
    return 0;
}
开发者ID:sdottaka,项目名称:cvsnt-sjis,代码行数:40,代码来源:macstore.c

示例9: BetterAddResource

// pass resFile as -1 to use the current file
OSErr BetterAddResource(short resFile,Handle theData,ResType type,short *id,StringPtr name,short mode)
{
	short		oldResFile=::CurResFile();
	OSErr		err=noErr;
	
	if (resFile!=-1)
		UseResFile(resFile);
	// If this resource exists then we may have some problems
	if (ResourceExists(-1,type,*id))
	{
		switch (mode)
		{
			case kOverwriteResource:
				if (!DeleteResource(-1,type,*id))
					err=rmvResFailed;
				break;
				
			case kUniqueID:
				*id=Unique1ID(type);
				break;
				
			case kBottleIt:
				err=userCanceledErr;
				break;
		}
	}
	
	if (!err)
	{
		// Now there is space for the resource lets add it
		AddResource(theData,type,*id,name ? name:"\p");
		err=ResError();
		if (err==noErr)
		{
			WriteResource(theData);
			err=ResError();
		}
	}
开发者ID:MaddTheSane,项目名称:tntbasic,代码行数:39,代码来源:Resources.cpp

示例10: FT_New_Face_From_Suitcase

  /* Create a new FT_Face from a file spec to a suitcase file. */
  static FT_Error
  FT_New_Face_From_Suitcase( 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;


    res_ref = FSpOpenResFile( spec, fsRdPerm );
    if ( ResError() )
      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;
  }
开发者ID:dikerex,项目名称:theqvd,代码行数:39,代码来源:ftmac.c

示例11: write_setting_s

void write_setting_s(void *handle, char const *key, char const *value) {
    int fd = *(int *)handle;
    Handle h;
    int id;
    OSErr error;
    Str255 pkey;

    UseResFile(fd);
    if (ResError() != noErr)
        fatalbox("Failed to open saved session (%d)", ResError());

    error = PtrToHand(value, &h, strlen(value));
    if (error != noErr)
	fatalbox("Failed to allocate memory");
    /* Put the data in a resource. */
    id = Unique1ID(FOUR_CHAR_CODE('TEXT'));
    if (ResError() != noErr)
	fatalbox("Failed to get ID for resource %s (%d)", key, ResError());
    c2pstrcpy(pkey, key);
    AddResource(h, FOUR_CHAR_CODE('TEXT'), id, pkey);
    if (ResError() != noErr)
	fatalbox("Failed to add resource %s (%d)", key, ResError());
}
开发者ID:sdottaka,项目名称:cvsnt-sjis,代码行数:23,代码来源:macstore.c

示例12: History

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Name:	MyPDEInitialize

	Input Parameters:
		context			:	The plugins context
		parentUserPane		:	the user pane to your your controls into
		ref			:	the reference to this PDE
		printSession		:	this holds the PM tickets
		
	Output Parameters:
		flags			:	feature flags that are supported by this PDE
		err			:	returns the error status

	Description:
		Initializes client interface. Creates controls and sets initial values


	
	Change History (most recent first):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static 
OSStatus MyPDEInitialize(	PMPDEContext	context, 
                        PMPDEFlags*		flags,
                        PMPDERef		ref,
                        ControlRef		parentUserPane,
                        PMPrintSession	printSession)
{
    OSStatus err = noErr;
    PageSetupPDEOnlyContextPtr myContext = NULL;	// Pointer to global data block.

    DebugMessage("PageSetupPDE MyPDEInitialize called\n");
    
    myContext = (PageSetupPDEOnlyContextPtr) context;
    
    if ((myContext != NULL) && (printSession != NULL))
    {		
		WindowRef theWindow = NULL;
		short savedResFile = CurResFile();
		UseResFile(myContext->theResFile);

		theWindow = GetControlOwner(parentUserPane);	// get the windowref from the user pane
		
		// the user panes rect is the rect we should use to draw our
		// controls into. The printing system calculates the user pane
		// size based on the maxh and maxv sizes returned from the 
		// Prologue function
		
		// Note that we are using the AutoToggleProc variant of the Radio Button control
		// This allows a hit on this control to be automatically processed by the ControlMgr
	
		// get controls
		myContext->thePrintTitleControlRef = GetNewControl(kPageSetupPDEControlID, theWindow);
	
		// embed controls
		EmbedControl(myContext->thePrintTitleControlRef, parentUserPane);
	
		// set controls as visible
		SetControlVisibility(myContext->thePrintTitleControlRef, true, false);
	
		// Set default value
		SetControlValue(myContext->thePrintTitleControlRef, 0);
		
		// Set flags
		*flags = kPMPDENoFlags;
		
		// Initialize this plugins controls based on the information in the 
		// PageSetup or PrintSettings ticket.
		err = MyPDESync(context, printSession, kSyncDirectionSetUserInterface);
		if (err == kPMKeyNotFound)
			err = noErr;

		UseResFile(savedResFile);
	}
    else
		err = kPMInvalidPDEContext;

    DebugPrintErr(err, "PageSetupPDE Error from MyPDEInitialize returned %d\n");

	return (err);

}
开发者ID:fruitsamples,项目名称:App,代码行数:81,代码来源:PageSetupPDE.c

示例13: CurResFile

char *QTTarg_GetStringFromUser (short thePromptStringIndex)
{
	short 			myItem;
	short 			mySavedResFile;
	GrafPtr			mySavedPort;
	DialogPtr		myDialog = NULL;
	short			myItemKind;
	Handle			myItemHandle;
	Rect			myItemRect;
	Str255			myString;
	char			*myCString = NULL;
	OSErr			myErr = noErr;

	//////////
	//
	// save the current resource file and graphics port
	//
	//////////

	mySavedResFile = CurResFile();
	GetPort(&mySavedPort);

	// set the application's resource file
	UseResFile(gAppResFile);

	//////////
	//
	// create the dialog box in which the user will enter a URL
	//
	//////////

	myDialog = GetNewDialog(kGetStr_DLOGID, NULL, (WindowPtr)-1L);
	if (myDialog == NULL)
		goto bail;

	QTFrame_ActivateController(QTFrame_GetFrontMovieWindow(), false);
	
	MacSetPort(GetDialogPort(myDialog));
	
	SetDialogDefaultItem(myDialog, kGetStr_OKButton);
	SetDialogCancelItem(myDialog, kGetStr_CancelButton);
	
	// set the prompt string	
	GetIndString(myString, kTextKindsResourceID, thePromptStringIndex);

	GetDialogItem(myDialog, kGetStr_StrLabelItem, &myItemKind, &myItemHandle, &myItemRect);
	SetDialogItemText(myItemHandle, myString);
	
	MacShowWindow(GetDialogWindow(myDialog));
	
	//////////
	//
	// display and handle events in the dialog box until the user clicks OK or Cancel
	//
	//////////
	
	do {
		ModalDialog(gModalFilterUPP, &myItem);
	} while ((myItem != kGetStr_OKButton) && (myItem != kGetStr_CancelButton));
	
	//////////
	//
	// handle the selected button
	//
	//////////
	
	if (myItem != kGetStr_OKButton) {
		myErr = userCanceledErr;
		goto bail;
	}
	
	// retrieve the edited text
	GetDialogItem(myDialog, kGetStr_StrTextItem, &myItemKind, &myItemHandle, &myItemRect);
	GetDialogItemText(myItemHandle, myString);
	myCString = QTUtils_ConvertPascalToCString(myString);
	
bail:
	// restore the previous resource file and graphics port
	MacSetPort(mySavedPort);
	UseResFile(mySavedResFile);
	
	if (myDialog != NULL)
		DisposeDialog(myDialog);

	return(myCString);
}
开发者ID:fruitsamples,项目名称:qtactiontargets.win,代码行数:86,代码来源:QTActionTargets.c

示例14: CFBundleGetValueForInfoDictionaryKey

bool PluginPackage::fetchInfo()
{
    if (!load())
        return false;

    WTF::RetainPtr<CFDictionaryRef> mimeDict;

    WTF::RetainPtr<CFTypeRef> mimeTypesFileName = CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginMIMETypesFilename"));
    if (mimeTypesFileName && CFGetTypeID(mimeTypesFileName.get()) == CFStringGetTypeID()) {

        WTF::RetainPtr<CFStringRef> fileName = (CFStringRef)mimeTypesFileName.get();
        WTF::RetainPtr<CFStringRef> homeDir = homeDirectoryPath().createCFString();
        WTF::RetainPtr<CFStringRef> path = CFStringCreateWithFormat(0, 0, CFSTR("%@/Library/Preferences/%@"), homeDir.get(), fileName.get());

        WTF::RetainPtr<CFDictionaryRef> plist = readPListFile(path.get(), /*createFile*/ false, m_module);
        if (plist) {
            // If the plist isn't localized, have the plug-in recreate it in the preferred language.
            WTF::RetainPtr<CFStringRef> localizationName =
                (CFStringRef)CFDictionaryGetValue(plist.get(), CFSTR("WebPluginLocalizationName"));
            CFLocaleRef locale = CFLocaleCopyCurrent();
            if (localizationName != CFLocaleGetIdentifier(locale))
                plist = readPListFile(path.get(), /*createFile*/ true, m_module);

            CFRelease(locale);
        } else {
            // Plist doesn't exist, ask the plug-in to create it.
            plist = readPListFile(path.get(), /*createFile*/ true, m_module);
        }

        mimeDict = (CFDictionaryRef)CFDictionaryGetValue(plist.get(), CFSTR("WebPluginMIMETypes"));
    }

    if (!mimeDict)
        mimeDict = (CFDictionaryRef)CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginMIMETypes"));

    if (mimeDict) {
        CFIndex propCount = CFDictionaryGetCount(mimeDict.get());
        Vector<const void*, 128> keys(propCount);
        Vector<const void*, 128> values(propCount);
        CFDictionaryGetKeysAndValues(mimeDict.get(), keys.data(), values.data());
        for (int i = 0; i < propCount; ++i) {
            String mimeType = (CFStringRef)keys[i];
            mimeType = mimeType.lower();

            WTF::RetainPtr<CFDictionaryRef> extensionsDict = (CFDictionaryRef)values[i];

            WTF:RetainPtr<CFNumberRef> enabled = (CFNumberRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeEnabled"));
            if (enabled) {
                int enabledValue = 0;
                if (CFNumberGetValue(enabled.get(), kCFNumberIntType, &enabledValue) && enabledValue == 0)
                    continue;
            }

            Vector<String> mimeExtensions;
            WTF::RetainPtr<CFArrayRef> extensions = (CFArrayRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginExtensions"));
            if (extensions) {
                CFIndex extensionCount = CFArrayGetCount(extensions.get());
                for (CFIndex i = 0; i < extensionCount; ++i) {
                    String extension =(CFStringRef)CFArrayGetValueAtIndex(extensions.get(), i);
                    extension = extension.lower();
                    mimeExtensions.append(extension);
                }
            }
            m_mimeToExtensions.set(mimeType, mimeExtensions);

            String description = (CFStringRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeDescription"));
            m_mimeToDescriptions.set(mimeType, description);
        }

        m_name = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginName"));
        m_description = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginDescription"));

    } else {
        int resFile = CFBundleOpenBundleResourceMap(m_module);

        UseResFile(resFile);

        Vector<String> mimes = stringListFromResourceId(MIMEListStringStringNumber);

        if (mimes.size() % 2 != 0)
            return false;

        Vector<String> descriptions = stringListFromResourceId(MIMEDescriptionStringNumber);
        if (descriptions.size() != mimes.size() / 2)
            return false;

        for (size_t i = 0;  i < mimes.size(); i += 2) {
            String mime = mimes[i].lower();
            Vector<String> extensions;
            mimes[i + 1].lower().split(UChar(','), extensions);

            m_mimeToExtensions.set(mime, extensions);

            m_mimeToDescriptions.set(mime, descriptions[i / 2]);
        }

        Vector<String> names = stringListFromResourceId(PluginNameOrDescriptionStringNumber);
        if (names.size() == 2) {
            m_description = names[0];
            m_name = names[1];
//.........这里部分代码省略.........
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:101,代码来源:PluginPackageMac.cpp

示例15: TclLoadFile

int
TclLoadFile(
    Tcl_Interp *interp,		/* Used for error reporting. */
    char *fileName,		/* Name of the file containing the desired
				 * code. */
    char *sym1, char *sym2,	/* Names of two procedures to look up in
				 * the file's symbol table. */
    Tcl_PackageInitProc **proc1Ptr,
    Tcl_PackageInitProc **proc2Ptr)
				/* Where to return the addresses corresponding
				 * to sym1 and sym2. */
{
    CFragConnectionID connID;
    Ptr dummy;
    OSErr err;
    CFragSymbolClass symClass;
    FSSpec fileSpec;
    short fragFileRef, saveFileRef;
    Handle fragResource;
    UInt32 offset = 0;
    UInt32 length = kCFragGoesToEOF;
    char packageName[255];
    Str255 errName;
    
    /*
     * First thing we must do is infer the package name from the sym1
     * variable.  This is kind of dumb since the caller actually knows
     * this value, it just doesn't give it to us.
     */
    strcpy(packageName, sym1);
    *packageName = (char) tolower(*packageName);
    packageName[strlen(packageName) - 5] = NULL;
    
    err = FSpLocationFromPath(strlen(fileName), fileName, &fileSpec);
    if (err != noErr) {
	interp->result = "could not locate shared library";
	return TCL_ERROR;
    }
    
    /*
     * See if this fragment has a 'cfrg' resource.  It will tell us were
     * to look for the fragment in the file.  If it doesn't exist we will
     * assume we have a ppc frag using the whole data fork.  If it does
     * exist we find the frag that matches the one we are looking for and
     * get the offset and size from the resource.
     */
    saveFileRef = CurResFile();
    SetResLoad(false);
    fragFileRef = FSpOpenResFile(&fileSpec, fsRdPerm);
    SetResLoad(true);
    if (fragFileRef != -1) {
	UseResFile(fragFileRef);
	fragResource = Get1Resource(kCFragResourceType, kCFragResourceID);
	HLock(fragResource);
	if (ResError() == noErr) {
	    CfrgItem* srcItem;
	    long itemCount, index;
	    Ptr itemStart;

	    itemCount = (*(CfrgHeaderPtrHand)fragResource)->itemCount;
	    itemStart = &(*(CfrgHeaderPtrHand)fragResource)->arrayStart;
	    for (index = 0; index < itemCount;
		 index++, itemStart += srcItem->itemSize) {
		srcItem = (CfrgItem*)itemStart;
		if (srcItem->archType != OUR_ARCH_TYPE) continue;
		if (!strncasecmp(packageName, (char *) srcItem->name + 1,
			srcItem->name[0])) {
		    offset = srcItem->codeOffset;
		    length = srcItem->codeLength;
		}
	    }
	}
	/*
	 * Close the resource file.  If the extension wants to reopen the
	 * resource fork it should use the tclMacLibrary.c file during it's
	 * construction.
	 */
	HUnlock(fragResource);
	ReleaseResource(fragResource);
	CloseResFile(fragFileRef);
	UseResFile(saveFileRef);
    }

    /*
     * Now we can attempt to load the fragement using the offset & length
     * obtained from the resource.  We don't worry about the main entry point
     * as we are going to search for specific entry points passed to us.
     */
    
    c2pstr(packageName);
    err = GetDiskFragment(&fileSpec, offset, length, (StringPtr) packageName,
	    kLoadCFrag, &connID, &dummy, errName);
    if (err != fragNoErr) {
	p2cstr(errName);
	Tcl_AppendResult(interp, "couldn't load file \"", fileName,
	    "\": ", errName, (char *) NULL);
	return TCL_ERROR;
    }
    
    c2pstr(sym1);
//.........这里部分代码省略.........
开发者ID:durandj,项目名称:devkitadv,代码行数:101,代码来源:tclMacLoad.c


注:本文中的UseResFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。