Esempio n. 1
0
static OSErr 
OpenLibraryResource(
    struct CFragInitBlock* initBlkPtr)
{
    /*
     * The 3.0 version of the Universal headers changed CFragInitBlock
     * to an opaque pointer type.  CFragSystem7InitBlock is now the
     * real pointer.
     */
     
#if !defined(UNIVERSAL_INTERFACES_VERSION) || (UNIVERSAL_INTERFACES_VERSION < 0x0300)
    struct CFragInitBlock *realInitBlkPtr = initBlkPtr;
#else 
    CFragSystem7InitBlock *realInitBlkPtr = (CFragSystem7InitBlock *) initBlkPtr;
#endif
    FSSpec* fileSpec = NULL;
    OSErr err = noErr;
    

    if (realInitBlkPtr->fragLocator.where == kDataForkCFragLocator) {
    	fileSpec = realInitBlkPtr->fragLocator.u.onDisk.fileSpec;
    } else if (realInitBlkPtr->fragLocator.where == kResourceCFragLocator) {
    	fileSpec = realInitBlkPtr->fragLocator.u.inSegs.fileSpec;
    } else {
    	err = resFNotFound;
    }

    /*
     * Open the resource fork for this library in read-only mode.  
     * This will make it the current res file, ahead of the 
     * application's own resources.
     */
    
    if (fileSpec != NULL) {
	ourResFile = FSpOpenResFile(fileSpec, fsRdPerm);
	if (ourResFile == kResFileNotOpened) {
	    err = ResError();
	} else {
#ifdef TCL_REGISTER_LIBRARY
	    ourResToken = Tcl_NewObj();
	    Tcl_IncrRefCount(ourResToken);
	    p2cstr(realInitBlkPtr->libName);
	    Tcl_SetStringObj(ourResToken, (char *) realInitBlkPtr->libName, -1);
	    c2pstr((char *) realInitBlkPtr->libName);
	    TclMacRegisterResourceFork(ourResFile, ourResToken,
	            TCL_RESOURCE_DONT_CLOSE);
#endif
            SetResFileAttrs(ourResFile, mapReadOnly);
	}
    }
    
    return err;
}
Esempio n. 2
0
static PyObject *Res_SetResFileAttrs(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    short refNum;
    short attrs;
#ifndef SetResFileAttrs
    PyMac_PRECHECK(SetResFileAttrs);
#endif
    if (!PyArg_ParseTuple(_args, "hh",
                          &refNum,
                          &attrs))
        return NULL;
    SetResFileAttrs(refNum,
                    attrs);
    {
        OSErr _err = ResError();
        if (_err != noErr) return PyMac_Error(_err);
    }
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}
Esempio n. 3
0
OSErr PAS_decodeMisc(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
	OSErr 		err;	
	short		outRefNum;
	PASMiscInfo	info;
	SInt32		infoSize;
	FInfo		theFInfo;
		
	
	infoSize	=	sizeof(PASMiscInfo);
	
	err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
	if (err != noErr)	return err;

	err	= FSRead( inRefNum, &infoSize, &info);
	if (err != noErr)	return err;

	if(infoSize != sizeof(PASMiscInfo))
	{
		return -1;
	}

	err = FSpOpenDF(outFile, fsRdWrPerm, &outRefNum);
	if (err != noErr)	return err;
	
	memset(&theFInfo, 0, sizeof(FInfo));   
		
	theFInfo.fdType		=	info.fileType;
	theFInfo.fdCreator	=	info.fileCreator;	
	theFInfo.fdFlags	=	info.fileFlags;
	
	err = FSpSetFInfo(outFile, &theFInfo);
	if (err != noErr)	return err;
		
	FSClose(outRefNum);
	
	if (info.fileHasResFork)
	{
		outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
		if (outRefNum < noErr)
		{
			// maybe it does not have one!
			
			FSpCreateResFile(outFile, info.fileCreator, info.fileType, smSystemScript);
			
			outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);	
			if (outRefNum < noErr) 
			{
				return err;
			}
		}
		
		SetResFileAttrs(outRefNum, info.fileResAttrs);
		
		
		CloseResFile(outRefNum);
	}	
	
	return noErr;
	
	

}
OSErr PAS_decodeMisc(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
	OSErr 		err = noErr;	
	short		outRefNum;
	PASMiscInfo	info;
	SInt32		infoSize;
	FInfo		theFInfo;
		
	
	infoSize	=	sizeof(PASMiscInfo);
	
	err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
	if (err != noErr)	return err;

	err	= FSRead( inRefNum, &infoSize, &info);
	if (err != noErr)	return err;

	if(infoSize != sizeof(PASMiscInfo))
	{
		return -1;
	}

	err = FSpOpenDF(outFile, fsRdWrPerm, &outRefNum);
	if (err != noErr)	return err;
	
	memset(&theFInfo, 0, sizeof(FInfo));   
		
	theFInfo.fdType		=	info.fileType;
	theFInfo.fdCreator	=	info.fileCreator;	
	theFInfo.fdFlags	=	info.fileFlags;
	
	err = FSpSetFInfo(outFile, &theFInfo);
	if (err != noErr)	return err;
		
	FSClose(outRefNum);
	
	if (info.fileHasResFork)
	{
		outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
		if (outRefNum < noErr)
		{
			// maybe it does not have one!
			
			FSpCreateResFile(outFile, info.fileCreator, info.fileType, smSystemScript);
			
			outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);	
			if (outRefNum < noErr) 
			{
				return outRefNum;
			}
		}
		
		SetResFileAttrs(outRefNum, info.fileResAttrs);
		
		
		CloseResFile(outRefNum);
	}	
	
	
	if(info.fileType == 'APPL')
	{
		// we need to add applications to the desktop database.
		
/*	FIX :: need to find DTSetAPPL() function	
		err = DTSetAPPL( NULL,
                    	 outFile->vRefNum,
			             info.fileCreator,
			             outFile->parID,
                         outFile->name);
*/	}
	
	
	return err;
	
	

}