Exemple #1
0
/* convert icns(icons for MacOS X) to IPIcon */
OSErr	XIconToIPIcon(const FSSpec *theFile,IPIconRec *ipIcon)
{
	OSErr	err;
	IconFamilyHandle	theIconFamily;
	short		refNum;
	long		count;
	
	if (isIconServicesAvailable)
	{
		/* open icns file */
		err=FSpOpenDF(theFile,fsRdPerm,&refNum);
		if (err!=noErr) return err;
		
		err=GetEOF(refNum,&count);
		if (err!=noErr)
		{
			FSClose(refNum);
			return err;
		}
		theIconFamily=(IconFamilyHandle)NewHandle(count);
		HLock((Handle)theIconFamily);
		err=FSRead(refNum,&count,*theIconFamily);
		HUnlock((Handle)theIconFamily);
		
		err=FSClose(refNum);
		
		/* convert IconFamily to IPIcon */
		err=IconFamilyToIPIcon(theIconFamily,ipIcon);
		
		DisposeHandle((Handle)theIconFamily);
		return err;
	}
	else
		return -1;
}
Exemple #2
0
void open_shapes_file(
	FSSpec *spec)
{
	short refNum;
	OSErr error;
	
	error= FSpOpenDF(spec, fsRdPerm, &refNum);
	if (error==noErr)
	{
		long count= MAXIMUM_COLLECTIONS*sizeof(struct collection_header);
		
		FSRead(refNum, &count, (void *) &collection_headers);
		if (error==noErr)
		{
		}
		
		if (error!=noErr)
		{
			FSClose(refNum);
			refNum= -1;
		}

		close_shapes_file();		
		shapes_file_refnum= refNum;
	}
	
	return;
}
char * ReadDataFile (long * pBufferSize, FSSpec * pfsspecData)
{
	NavReplyRecord replyNav;
	NavTypeListHandle hTypeList = (NavTypeListHandle) NewHandleClear (sizeof (NavTypeList) + sizeof (OSType) * 1);
	AEKeyword theKeyword;
	DescType actualType;
	Size actualSize;
	OSStatus err = noErr;
    short fileRef;
    char * pFileBuffer;

	HLock ((Handle) hTypeList);
	(**hTypeList).osTypeCount = 2;
	(**hTypeList).osType[0] = 'TEXT';
	(**hTypeList).osType[1] = '????';

    // select sprite file
	err = NavChooseFile (NULL, &replyNav, NULL, NULL, NULL, NULL, hTypeList, NULL); 
	if ((err == noErr) && (replyNav.validRecord))
		err = AEGetNthPtr (&(replyNav.selection), 1, typeFSS, &theKeyword, &actualType,
						   pfsspecData, sizeof (FSSpec), &actualSize);
	NavDisposeReply (&replyNav);
	if (err != noErr)
		return false;
    FSpOpenDF(pfsspecData, fsRdPerm, &fileRef);
    GetEOF(fileRef, pBufferSize);
    pFileBuffer = (char *) NewPtrClear (*pBufferSize);
    FSRead (fileRef, pBufferSize, pFileBuffer);
    FSClose (fileRef);
	return pFileBuffer;
}
int asyncFileClose(AsyncFile *f) {
  /* Close the given asynchronous file. */

	AsyncFileState *state;
	short int volRefNum;
	OSErr err;

	if (!asyncFileValid(f)) return 0;  /* already closed */
	state = f->state;

	err = GetVRefNum(state->refNum, &volRefNum);
	success(err == noErr);

	err = FSClose(state->refNum);
	success(err == noErr);

	if (!interpreterProxy->failed()) err = FlushVol(NULL, volRefNum);
	success(err == noErr);

    if (asyncFileCompletionProc != nil)
        DisposeIOCompletionUPP(asyncFileCompletionProc);
  
	asyncFileCompletionProc = nil;
	if (state->bufferPtr != nil) DisposePtr(state->bufferPtr);
	DisposePtr((void *) f->state);
	f->state = nil;
	f->sessionID = 0;
	return 0;
}
Exemple #5
0
static void
InitWinFile (void)
{
	StringHandle sh;
	long len;
	short ref = 0;

	if (winFileInit) {
		return;
	}
/* We trust the glue. If there's an error, store in game dir. */
	if (FindFolder (kOnSystemDisk, kPreferencesFolderType, kCreateFolder ,
		&winFileVol, &winFileDir)) {
		winFileVol = 0;
		winFileDir = 0;
	}
	sh = GetString (128);
	if (sh && *sh) {
		BlockMove (*sh, winFileName, **sh + 1);
		ReleaseResource ((Handle) sh);
	}
	if (HOpen (winFileVol, winFileDir, winFileName, fsRdPerm, &ref)) {
		return;
	}
	len = sizeof (savePos);
	if (!FSRead (ref, &len, savePos)) {
		winFileInit = 1;
	}
	FSClose (ref);
}
/*__________________________________________________________________________*/
Boolean SaveDriverState (short refnum, StringPtr file, OSType creator, OSType type)
{
	FSSpec spec; OSErr err; TDriverInfos dInfos;
	long size, dirID; short vrefNum, ref;
	Ptr ptr;
	
	if (FindMidiShareFolder (true, &vrefNum, &dirID) != noErr) return false;
	if (!MidiGetDriverInfos (refnum, &dInfos)) return false;

	size = Get1DriverStateSize (dInfos.slots);
	if (!size) return true;
	
	ptr = NewPtrSys(size);
	if (!ptr) return false;
		
	Get1DriverState (refnum, dInfos.slots, ptr, size);
	err = FSMakeFSSpec(vrefNum, dirID, file, &spec);
	if (err == fnfErr)
		err = FSpCreate (&spec, creator, type, smSystemScript);
	if (err != noErr) goto err;
		err = FSpOpenDF (&spec, fsWrPerm, &ref);
	if (err != noErr) goto err;
		err = FSWrite (ref, &size, ptr);
	FSClose (ref);
	DisposePtr (ptr);
	return err == noErr;

err:
	DisposePtr (ptr);
	return false;
}
Exemple #7
0
void creature_type_data_dump()
{
	short i;
	char get_text[1280];
	FILE *data_dump_file_id;
	long len;

	 sprintf(get_text,"%s - Creature Type Data.txt",scenario.scen_name);
	if (NULL == (data_dump_file_id = fopen(get_text, "wb"))) {
		oops_error(11);
		return;
		}

	sprintf((char *)get_text,"\r\rScenario Creature Type Data for %s:\r\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	sprintf((char *)get_text,"i\tname\tlevel\twhich_to_add_to[0]\twhich_to_add_to[1]\twhich_to_add_to[2]\twhich_to_add_to[3]\twhich_to_add_to[4]\twhich_to_add_to[5]\thow_much[0]\thow_much[1]\thow_much[2]\thow_much[3]\thow_much[4]\thow_much[5]\titems[0]\titems[1]\titems[2]\titems[3]\titems[4]\titems[5]\titems[6]\titems[7]\titem_chances[0]\titem_chances[1]\titem_chances[2]\titem_chances[3]\titem_chances[4]\titem_chances[5]\titem_chances[6]\titem_chances[7]\thp_bonus\tsp_bonus\tspec_abil\tdefault_attitude\tspecies\timmunities[0]\timmunities[1]\timmunities[2]\timmunities[3]\timmunities[4]\timmunities[5]\tnatural_armor\tchar_graphic.which_sheet\tchar_graphic.which_icon\tchar_graphic.graphic_adjust\tchar_upper_graphic_sheet\tsmall_or_large_template\ta[0]\ta[1]\ta[2]\ta1_type\ta23_type\tap_bonus\tdefault_script\tdefault_strategy\tdefault_aggression\tdefault_courage\tsummon_class\textra[0]\textra[1]\textra[2]\textra[3]\textra[4]\textra[5]\textra[6]\textra[7]\textra[8]\textra[9]\r\r");
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);

	sprintf((char *)get_text,"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\t27\t28\t29\t30\t31\t32\t33\t34\t35\t36\t37\t38\t39\t40\t41\t42\t43\t44\t45\t46\t47\t48\t49\t50\t51\t52\t53\t54\t55\t56\t57\t58\t59\t60\t61\t62\t63\t64\t65\t66\t67\t68\t69\r\r");
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);

		for (i = 0; i < 256; i++) {
		sprintf((char *)get_text,"%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r",i,scen_data.scen_creatures[i].name,scen_data.scen_creatures[i].level,scen_data.scen_creatures[i].which_to_add_to[0],scen_data.scen_creatures[i].which_to_add_to[1],scen_data.scen_creatures[i].which_to_add_to[2],scen_data.scen_creatures[i].which_to_add_to[3],scen_data.scen_creatures[i].which_to_add_to[4],scen_data.scen_creatures[i].which_to_add_to[5],scen_data.scen_creatures[i].how_much[0],scen_data.scen_creatures[i].how_much[1],scen_data.scen_creatures[i].how_much[2],scen_data.scen_creatures[i].how_much[3],scen_data.scen_creatures[i].how_much[4],scen_data.scen_creatures[i].how_much[5],scen_data.scen_creatures[i].items[0],scen_data.scen_creatures[i].items[1],scen_data.scen_creatures[i].items[2],scen_data.scen_creatures[i].items[3],scen_data.scen_creatures[i].items[4],scen_data.scen_creatures[i].items[5],scen_data.scen_creatures[i].items[6],scen_data.scen_creatures[i].items[7],scen_data.scen_creatures[i].item_chances[0],scen_data.scen_creatures[i].item_chances[1],scen_data.scen_creatures[i].item_chances[2],scen_data.scen_creatures[i].item_chances[3],scen_data.scen_creatures[i].item_chances[4],scen_data.scen_creatures[i].item_chances[5],scen_data.scen_creatures[i].item_chances[6],scen_data.scen_creatures[i].item_chances[7],scen_data.scen_creatures[i].hp_bonus,scen_data.scen_creatures[i].sp_bonus,scen_data.scen_creatures[i].spec_abil,scen_data.scen_creatures[i].default_attitude,scen_data.scen_creatures[i].species,scen_data.scen_creatures[i].immunities[0],scen_data.scen_creatures[i].immunities[1],scen_data.scen_creatures[i].immunities[2],scen_data.scen_creatures[i].immunities[3],scen_data.scen_creatures[i].immunities[4],scen_data.scen_creatures[i].immunities[5],scen_data.scen_creatures[i].natural_armor,scen_data.scen_creatures[i].char_graphic.which_sheet,scen_data.scen_creatures[i].char_graphic.which_icon,scen_data.scen_creatures[i].char_graphic.graphic_adjust,scen_data.scen_creatures[i].char_upper_graphic_sheet,scen_data.scen_creatures[i].small_or_large_template,scen_data.scen_creatures[i].a[0],scen_data.scen_creatures[i].a[1],scen_data.scen_creatures[i].a[2],scen_data.scen_creatures[i].a1_type,scen_data.scen_creatures[i].a23_type,scen_data.scen_creatures[i].ap_bonus,scen_data.scen_creatures[i].default_script,scen_data.scen_creatures[i].default_strategy,scen_data.scen_creatures[i].default_aggression,scen_data.scen_creatures[i].default_courage,scen_data.scen_creatures[i].summon_class,scen_data.scen_creatures[i].extra[0],scen_data.scen_creatures[i].extra[1],scen_data.scen_creatures[i].extra[2],scen_data.scen_creatures[i].extra[3],scen_data.scen_creatures[i].extra[4],scen_data.scen_creatures[i].extra[5],scen_data.scen_creatures[i].extra[6],scen_data.scen_creatures[i].extra[7],scen_data.scen_creatures[i].extra[8],scen_data.scen_creatures[i].extra[9]);
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
		}
		sprintf((char *)get_text,"\r\r");
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
	FSClose(data_dump_file_id);
}	
int __PHYSFS_platformClose(void *opaque)
{
    SInt16 ref = *((SInt16 *) opaque);
    SInt16 vRefNum;
    Str63 volName;
    int flushVol = 0;

    if (GetVRefNum(ref, &vRefNum) == noErr)
    {
        HParamBlockRec hpbr;
        memset(&hpbr, '\0', sizeof (HParamBlockRec));
        hpbr.volumeParam.ioNamePtr = volName;
        hpbr.volumeParam.ioVRefNum = vRefNum;
        hpbr.volumeParam.ioVolIndex = 0;
        if (PBHGetVInfoSync(&hpbr) == noErr)
            flushVol = 1;
    } /* if */

    BAIL_IF_MACRO(oserr(FSClose(ref)) != noErr, NULL, 0);
    free(opaque);

    if (flushVol)
        FlushVol(volName, vRefNum);  /* update catalog info, etc. */

    return(1);
} /* __PHYSFS_platformClose */
Exemple #9
0
OSErr PAS_encodeData(FSSpec *inFile, short outRefNum)
{
	OSErr 		err;	
	short		inRefNum;
	Ptr 		buffer;
	SInt32 		currentRead = 	PAS_BUFFER_SIZE;
		
	buffer	=	NewPtr(currentRead);

	err = FSpOpenDF(inFile, fsRdPerm, &inRefNum);
	if (err != noErr)	return err;
	
	while ( currentRead > 0 )
    {
		err	= FSRead( inRefNum, &currentRead, buffer);
		if (err != noErr && err != eofErr)	return err;
		
		err = FSWrite(outRefNum, &currentRead, buffer);
		if (err != noErr)	return err;
	}
	
	FSClose(inRefNum);
	
	DisposePtr(buffer);
	
	return noErr;
}
Boolean PICloseFileAndMakeAlias (FSSpec& fsSpec,
					 FileHandle fRefNum, Boolean sameNames,
					 Boolean *dirty, AliasHandle *alias, short *result)
{
//	FSSpec			spec;
	OSErr			gotErr;
	
	// Close the file if it is open.
	if (fRefNum != 0)
		(void) TestAndStoreResult (result, FSClose (fRefNum));
		
	// Delete the file if we had an error.	
	 if (*result != noErr)
		 (void) FSpDelete (&fsSpec);
			
	// Flush the volume anyway.
	if (!TestAndStoreResult (result, FlushVol (NULL, fsSpec.vRefNum))) return FALSE;
	
	// Mark the file as clean.
	*dirty = FALSE;
	
	/* create alias for scripting system */
	
	if (sameNames)
	{ // didn't enter new filename, so set filename to nothing
		fsSpec.name[ (fsSpec.name[0] = 0)+1 ] = 0;
	} // otherwise use filename and store entire reference

	gotErr = NewAlias(nil, &fsSpec, alias);

	return (gotErr == noErr);
}
Exemple #11
0
void floor_type_data_dump()
{
	short i;
	char get_text[1280];
	FILE *data_dump_file_id;
	long len;

	 sprintf(get_text,"%s - Floor Type Data.txt",scenario.scen_name);
	if (NULL == (data_dump_file_id = fopen(get_text, "wb"))) {
		oops_error(11);
		return;
		}

	sprintf((char *)get_text,"\r\rScenario Floor Type Data for %s:\r\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	
	sprintf((char *)get_text,"i\tfloor_name\tpic.which_sheet\tpic.which_icon\tpic.graphic_adjust\ted_pic.which_sheet\ted_pic.which_icon\ted_pic.graphic_adjust\tblocked\tstep_sound\tlight_radius\tfloor_height\tnum_anim_steps\tspecial\teffect_adjust\tis_water\tis_floor\tis_ground\tis_rough\tfly_over\tshimmers\toutdoor_combat_town_used\tshortcut_key\textra[0]\textra[1]\textra[2]\textra[3]\textra[4]\textra[5]\r\r");
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);

	sprintf((char *)get_text,"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\t27\t28\t29\r\r");
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);

		for (i = 0; i < 256; i++) {
		sprintf((char *)get_text,"%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r",i,scen_data.scen_floors[i].floor_name,scen_data.scen_floors[i].pic.which_sheet,scen_data.scen_floors[i].pic.which_icon,scen_data.scen_floors[i].pic.graphic_adjust,scen_data.scen_floors[i].ed_pic.which_sheet,scen_data.scen_floors[i].ed_pic.which_icon,scen_data.scen_floors[i].ed_pic.graphic_adjust,scen_data.scen_floors[i].blocked,scen_data.scen_floors[i].step_sound,scen_data.scen_floors[i].light_radius,scen_data.scen_floors[i].floor_height,scen_data.scen_floors[i].num_anim_steps,scen_data.scen_floors[i].special,scen_data.scen_floors[i].effect_adjust,scen_data.scen_floors[i].is_water,scen_data.scen_floors[i].is_floor,scen_data.scen_floors[i].is_ground,scen_data.scen_floors[i].is_rough,scen_data.scen_floors[i].fly_over,scen_data.scen_floors[i].shimmers,scen_data.scen_floors[i].outdoor_combat_town_used,scen_data.scen_floors[i].shortcut_key,scen_data.scen_floors[i].extra[0],scen_data.scen_floors[i].extra[1],scen_data.scen_floors[i].extra[2],scen_data.scen_floors[i].extra[3],scen_data.scen_floors[i].extra[4],scen_data.scen_floors[i].extra[5]);
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
		}
		sprintf((char *)get_text,"\r\r");
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
	FSClose(data_dump_file_id);
}	
Exemple #12
0
/*
 * We don't bother with the usual FSpExchangeFiles dance here because
 * it doesn't really matter if the old random seed gets lost.
 */
void write_random_seed(void *data, int len)
{
    short puttyVRefNum;
    long puttyDirID;
    OSErr error;
    FSSpec dstfile;
    short refnum;
    long count = len;

    if (get_putty_dir(kCreateFolder, &puttyVRefNum, &puttyDirID) != noErr)
	return;

    error = FSMakeFSSpec(puttyVRefNum, puttyDirID, "\pPuTTY Random Seed",
			 &dstfile);
    if (error == fnfErr) {
	/* Set up standard resources */
	FSpCreateResFile(&dstfile, INTERNAL_CREATOR, SEED_TYPE, smRoman);
	refnum = FSpOpenResFile(&dstfile, fsWrPerm);
	if (ResError() == noErr) {
	    copy_resource('STR ', -16397);
	    CloseResFile(refnum);
	}
    } else if (error != noErr) return;

    if (FSpOpenDF(&dstfile, fsWrPerm, &refnum) != noErr) return;
    FSWrite(refnum, &count, data);
    FSClose(refnum);

    return;
}
Exemple #13
0
unsigned long PAS_getDataSize(FSSpec *spec)
{
	short		refNum;
	OSErr		err;
	Str255 		temp;	
	CInfoPBRec 	cbrec;
	err = FSpOpenDF(spec, fsRdPerm, &refNum);

	memcpy( temp, spec->name, spec->name[0] + 1);

	cbrec.hFileInfo.ioNamePtr 		= temp;
	cbrec.hFileInfo.ioDirID 		= spec->parID;
	cbrec.hFileInfo.ioVRefNum 		= spec->vRefNum;
	cbrec.hFileInfo.ioFDirIndex     = 0;

	err = PBGetCatInfoSync(&cbrec);
	FSClose(refNum);
	
	if(err != noErr)
	{
		cbrec.hFileInfo.ioFlLgLen = err;
	}

	return (cbrec.hFileInfo.ioFlLgLen);
}
Exemple #14
0
void item_data_dump()
{
	short i;
	char get_text[580];
	FILE *data_dump_file_id;
	long len;

	 sprintf(get_text,"%s - Item Data.txt",scenario.scen_name);
	if (NULL == (data_dump_file_id = fopen(get_text, "wb"))) {
		oops_error(11);
		return;
		}

	sprintf((char *)get_text,"\r\rScenario Item Data for %s:\r\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	sprintf((char *)get_text,"\r\ritem#\tfull_name\tvariety\tdamage\tbonus\tweap_type\tprotection\tcharges\tencumbrance\twhich_sheet\twhich_icon\tgraphic_adjust\tinven_icon\tmissile_anim_type\tability_in_slot[0]\tability_strength[0]\tability_in_slot[1]\tability_strength[1]\tability_in_slot[2]\tability_strength[2]\tability_in_slot[3]\tability_strength[3]\tspecial_class\tvalue\tweight\tvalue_class\tident\tmagic\tcursed\tonce_per_day\tjunk_item\textra[0]\textra[1]\textra[2]\textra[3]\tname\r\r");
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);

	sprintf((char *)get_text,"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\t27\t28\t29\t30\t31\t32\t33\t34\t35\t36\r\r");
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	
		for (i = 0; i < NUM_SCEN_ITEMS; i++) {
		sprintf((char *)get_text,"%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%s\r",(int)i,scen_data.scen_items[i].full_name,scen_data.scen_items[i].variety,scen_data.scen_items[i].damage,scen_data.scen_items[i].bonus,scen_data.scen_items[i].weap_type,scen_data.scen_items[i].protection,scen_data.scen_items[i].charges,scen_data.scen_items[i].encumbrance,scen_data.scen_items[i].item_floor_graphic.which_sheet ,scen_data.scen_items[i].item_floor_graphic.which_icon ,scen_data.scen_items[i].item_floor_graphic.graphic_adjust,scen_data.scen_items[i].inven_icon,scen_data.scen_items[i].missile_anim_type,scen_data.scen_items[i].ability_in_slot[0],scen_data.scen_items[i].ability_strength[0],scen_data.scen_items[i].ability_in_slot[1],scen_data.scen_items[i].ability_strength[1],scen_data.scen_items[i].ability_in_slot[2],scen_data.scen_items[i].ability_strength[2],scen_data.scen_items[i].ability_in_slot[3],scen_data.scen_items[i].ability_strength[3],scen_data.scen_items[i].special_class,scen_data.scen_items[i].value,scen_data.scen_items[i].weight,scen_data.scen_items[i].value_class,scen_data.scen_items[i].ident,scen_data.scen_items[i].magic,scen_data.scen_items[i].cursed,scen_data.scen_items[i].once_per_day,scen_data.scen_items[i].junk_item,scen_data.scen_items[i].extra[0],scen_data.scen_items[i].extra[1],scen_data.scen_items[i].extra[2],scen_data.scen_items[i].extra[3],scen_data.scen_items[i].name);
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
		}
		sprintf((char *)get_text,"\r\r");
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
	FSClose(data_dump_file_id);
}	
Exemple #15
0
void terrain_type_data_dump()
{
	short i;
	char get_text[1280];
	FILE *data_dump_file_id;
	long len;

	 sprintf(get_text,"%s - Terrain Type Data.txt",scenario.scen_name);
	if (NULL == (data_dump_file_id = fopen(get_text, "wb"))) {
		oops_error(11);
		return;
		}

	sprintf((char *)get_text,"\r\rScenario Terrain Type Data for %s:\r\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	sprintf((char *)get_text,"i\tter_name\tpic.which_sheet\tpic.which_icon\tpic.graphic_adjust\tcut_away_pic.which_sheet\tcut_away_pic.which_icon\tcut_away_pic.graphic_adjust\ted_pic.which_sheet\ted_pic.which_icon\ted_pic.graphic_adjust\ticon_offset_x\ticon_offset_y\tsecond_icon\tsecond_icon_offset_x\tsecond_icon_offset_y\tcut_away_second_icon\tcut_away_offset_x\tcut_away_offset_y\tanim_steps\tmove_block[0]\tmove_block[1]\tmove_block[2]\tmove_block[3]\tsee_block[0]\tsee_block[1]\tsee_block[2]\tsee_block[3]\tblocks_view[0]\tblocks_view[1]\tblocks_view[2]\tblocks_view[3]\theight_adj\tsuppress_floor\tlight_radius\tstep_sound\tshortcut_key\tcrumble_type\tbeam_hit_type\tterrain_to_crumble_to\thidden_town_terrain\tswap_terrain\tis_bridge\tis_road\tcan_look_at\tdraw_on_automap\tdefault_script\tshimmers\toutdoor_combat_town_used\tspecial\teffect_adjust\r\r");
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);

	sprintf((char *)get_text,"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\t27\t28\t29\t30\t31\t32\t33\t34\t35\t36\t37\t38\t39\t40\t41\t42\t43\t44\t45\t46\t47\t48\t49\t50\t51\r\r");
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);

		for (i = 0; i < 512; i++) {
		sprintf((char *)get_text,"%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%s\t%d\t%d\t%d\t%d\r",(int)i,scen_data.scen_ter_types[i].ter_name,scen_data.scen_ter_types[i].pic.which_sheet,scen_data.scen_ter_types[i].pic.which_icon,scen_data.scen_ter_types[i].pic.graphic_adjust,scen_data.scen_ter_types[i].cut_away_pic.which_sheet,scen_data.scen_ter_types[i].cut_away_pic.which_icon,scen_data.scen_ter_types[i].cut_away_pic.graphic_adjust,scen_data.scen_ter_types[i].ed_pic.which_sheet,scen_data.scen_ter_types[i].ed_pic.which_icon,scen_data.scen_ter_types[i].ed_pic.graphic_adjust,scen_data.scen_ter_types[i].icon_offset_x,scen_data.scen_ter_types[i].icon_offset_y,scen_data.scen_ter_types[i].second_icon,scen_data.scen_ter_types[i].second_icon_offset_x,scen_data.scen_ter_types[i].second_icon_offset_y,scen_data.scen_ter_types[i].cut_away_second_icon,scen_data.scen_ter_types[i].cut_away_offset_x,scen_data.scen_ter_types[i].cut_away_offset_y,scen_data.scen_ter_types[i].anim_steps,scen_data.scen_ter_types[i].move_block[0],scen_data.scen_ter_types[i].move_block[1],scen_data.scen_ter_types[i].move_block[2],scen_data.scen_ter_types[i].move_block[3],scen_data.scen_ter_types[i].see_block[0],scen_data.scen_ter_types[i].see_block[1],scen_data.scen_ter_types[i].see_block[2],scen_data.scen_ter_types[i].see_block[3],scen_data.scen_ter_types[i].blocks_view[0],scen_data.scen_ter_types[i].blocks_view[1],scen_data.scen_ter_types[i].blocks_view[2],scen_data.scen_ter_types[i].blocks_view[3],scen_data.scen_ter_types[i].height_adj,scen_data.scen_ter_types[i].suppress_floor,scen_data.scen_ter_types[i].light_radius,scen_data.scen_ter_types[i].step_sound,scen_data.scen_ter_types[i].shortcut_key,scen_data.scen_ter_types[i].crumble_type,scen_data.scen_ter_types[i].beam_hit_type,scen_data.scen_ter_types[i].terrain_to_crumble_to,scen_data.scen_ter_types[i].hidden_town_terrain,scen_data.scen_ter_types[i].swap_terrain,scen_data.scen_ter_types[i].is_bridge,scen_data.scen_ter_types[i].is_road,scen_data.scen_ter_types[i].can_look_at,scen_data.scen_ter_types[i].draw_on_automap,scen_data.scen_ter_types[i].default_script,scen_data.scen_ter_types[i].shimmers,scen_data.scen_ter_types[i].outdoor_combat_town_used,scen_data.scen_ter_types[i].special,scen_data.scen_ter_types[i].effect_adjust);
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
		}
		sprintf((char *)get_text,"\r\r");
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
	FSClose(data_dump_file_id);
}	
Exemple #16
0
void loadMacros(NewMacroInfo *macrost, FSSpec *theFile)
{
	SFReply		sfr;
	long		junk;
	SFTypeList	typesok = {'TEXT'};
	Point		where;
	FSSpec		macros;
	OSErr 		err;
	short 		fileRef;
	where.h=100;where.v=100;
	if (theFile == 0L)
	{
		SFGetFile( where, NULL, 0L, 1, typesok, 0L, &sfr);
		if (!sfr.good) return;
		BlockMoveData(&sfr.fName, macros.name, (*sfr.fName)+1); 
		GetWDInfo(sfr.vRefNum, &macros.vRefNum, &macros.parID, &junk);
		err = HOpenDF(macros.vRefNum, macros.parID, macros.name, fsRdPerm, &fileRef);
	}
	else
		err = HOpenDF(theFile->vRefNum, theFile->parID, theFile->name, fsRdPerm, &fileRef);
	
	if (err != noErr)
		return;
	parseMacroFile(macrost, fileRef);
	FSClose(fileRef);
}
Exemple #17
0
Fichier : ugView.c Projet : rolk/ug
static void SaveToPICT (SFReply *reply)
{
  Rect MyPicFrame ;
  CQDProcs MyPicProcs,*SavePtr ;
  OSErr error ;
  long LongZero, LongCount ;
  short Counter ;
  CGrafPtr theCGrafPort;
  WindowPtr theWindow;
  OpenCPicParams myOpenCPicParams;

  /* get my window */
  theWindow = myWindow.theWindow;
  theCGrafPort = (CGrafPtr) theWindow;

  error = FSOpen(reply->fName, reply->vRefNum, &FileSys_RefNR ) ;
  SetStdCProcs ( &MyPicProcs ) ;
  SavePtr = (CQDProcs *) theWindow->grafProcs;
  theWindow->grafProcs   = (QDProcs *) (&MyPicProcs) ;
  MyPicProcs.putPicProc  = NewQDPutPicProc(MyPutPicData) ;

  LongZero   = 0 ;
  LongCount  = 4 ;

  PicCounter = sizeof(Picture) ;
  for (Counter=1 ; Counter <= 128+sizeof(Picture) ; Counter++ )
    error = FSWrite(FileSys_RefNR, &LongCount, &LongZero );
  error = SetFPos(FileSys_RefNR, fsFromStart, 512+sizeof(Picture)) ;

  SetPort((GrafPtr)(theWindow));
  MyPicFrame = ((GrafPtr)(theWindow))->portRect;
  MyPicFrame.right = MyPicFrame.right-16;
  MyPicFrame.bottom = MyPicFrame.bottom-16;
  MyPicHand  = NULL ;
  myOpenCPicParams.srcRect        = MyPicFrame;
  myOpenCPicParams.hRes           = cHRes;
  myOpenCPicParams.vRes           = cVRes;
  myOpenCPicParams.version        = -2;
  myOpenCPicParams.reserved1      = 0;
  myOpenCPicParams.reserved2      = 0;
  MyPicHand  = OpenCPicture ( &myOpenCPicParams );
  ClipRect(&MyPicFrame);

  /* draw picture */
  RefreshCommand();

  ClosePicture() ;

  /* close File */
  error = SetFPos(FileSys_RefNR, fsFromStart, 512) ;
  LongCount = sizeof(Picture) ;
  error = FSWrite(FileSys_RefNR, &LongCount, (void *) (*MyPicHand) );
  error = FSClose(FileSys_RefNR) ;

  KillPicture(MyPicHand);
  theWindow->grafProcs   = (QDProcs *) SavePtr ;

  return;
}
Exemple #18
0
void Files::EndLoad()
{
	if (sFile != -1) {
		FSClose( sFile );
	}
	
	sFile = -1;
}
Exemple #19
0
/* デバッグファイルを閉じる */
void CloseDebugFile(void)
{
	OSErr	err;
	
	if (debugFileRefNum<=0) return;
	
	err=FSClose(debugFileRefNum);
}
Exemple #20
0
OSErr PAS_encodeMisc(FSSpec *inFile, short outRefNum)
{
	OSErr 		err;	
	short		inRefNum;
	PASMiscInfo	infoBlock;
	FInfo		fInfo;
	SInt32		currentRead;
	
	err = FSpOpenDF(inFile, fsRdPerm, &inRefNum);
	if (err != noErr)	return err;
	
	memset(&infoBlock, 0, sizeof(PASMiscInfo));   
	
	err = FSpGetFInfo(inFile, &fInfo);
	if (err != noErr)	return err;
	
	infoBlock.fileType		=	fInfo.fdType;
	infoBlock.fileCreator	=	fInfo.fdCreator;
	infoBlock.fileFlags		=	fInfo.fdFlags;
	
		
	FSClose(inRefNum);
	
	
	inRefNum = FSpOpenResFile(inFile, fsRdPerm);
	if (inRefNum > noErr)
	{
		infoBlock.fileHasResFork	= 1;
		infoBlock.fileResAttrs 		= GetResFileAttrs(inRefNum);
		FSClose(inRefNum);
	}
	else
	{
		infoBlock.fileHasResFork	= 0;
		infoBlock.fileResAttrs 		= 0;
	}
	currentRead	= sizeof(PASMiscInfo);
	
	err = FSWrite(outRefNum, &currentRead, &infoBlock);
	if (err != noErr)	return err;
		
	CloseResFile(inRefNum);
	
	return noErr;
}
Exemple #21
0
/* --------------- private code */
static void shutdown_music_handler(
	void)
{
	if(music_state && music_state->initialized)
	{
		free_music_channel();
		FSClose(music_state->song_file_refnum);
	}
}
Exemple #22
0
PicHandle OpenPICTFile(
	short 	vRefNum, 
	Str255 	fName)
{
	short		fRefNum;
	OSErr		err;
	long		curEOF;
	PicHandle	myPic;
	long 		count;
	Ptr 		buffer;
	
	/* open PICT file */
	err = FSOpen(fName, vRefNum, &fRefNum);
	if (err != 0) {
		/*printf("Error - cannot open file\n"); */
		exit(-1);
	}
	
	/* get size of file */
	err = GetEOF(fRefNum, &curEOF);
	if (err != 0) {
		/*printf("Error - cannot get EOF\n"); */
		exit(-2);
	}
	
	/* move the file mark to 512 */
	err = SetFPos(fRefNum, SEEK_SET, 512L);
	if (err != 0) {
		/*printf("Error - cannot seek 512\n"); */
		exit(-3);
	}

	/* size of data to read */
	count = curEOF - 512;
	
	/* create the PicHandle */
	myPic = (PicHandle)NewHandle(count);
	HLock((Handle)myPic);
	
	/* read the PICT info */
	buffer = (Ptr)(*myPic);
	err = FSRead(fRefNum, &count, buffer);
	if (err != 0) {
		/*printf("Error - cannot read\n");*/
		exit(-4);
	}
	HUnlock((Handle)myPic);
	
	/* release the file */
	err = FSClose(fRefNum);
	if (err != 0) {
		/*printf("Error - cannot close file \n"); */
		exit(-5);
	}
	
	return (myPic);
}
/////////////////////////////////////
// Name:	FSOpen
// Purpose:	this will open a file
//			relative to game paths
//			(maybe from pack files)
// Output:	file opened
// Return:	file handle
/////////////////////////////////////
hFILE FSOpen(const tCHAR *filepath, const tCHAR *mode)
{
	if(!filepath) return 0;

	hFILE fp=(hFILE)MemAlloc(sizeof(FSFile));

	if(fp)
	{
		wstring path;

		//if there are no paths
		if(!g_main || g_main->paths->size() == 0)
		{
			FSPath fsPath;
			fsPath.flag = 0;
			fsPath.uf = 0;
			fsPath.str = L"\0";

			//try to open the file
			if(_Open(fp, fsPath, filepath, mode) != TRUE)
			{ FSClose(fp); fp = 0; }
		}
		else
		{
			s8 ret = FALSE;

			//go through the list to find where this file is
			for(list<FSPath>::iterator i = g_main->paths->begin(); i != g_main->paths->end(); i++)
			{
				//try to open the file
				ret = _Open(fp, (*i), filepath, mode);

				if(ret != FALSE)
					break;
			}

			//failed to find the file
			if(ret == FALSE || ret == -1) { FSClose(fp); fp = 0; }
		}
	}

	return fp;
}
Exemple #24
0
void oldsaveMacros(FSSpec *theFile)
{
	SFReply		whereReply;
	short 		refNum,exist;
	FSSpec		macroFile;
	long		junk;
	short 		i;
	char		temp[256], temp2[256];
	Point		where;
	OSErr		err;
	Str255		tempString,tempString2;

	where.h = 100; where.v = 100;

	GetIndString(tempString,MISC_STRINGS,SAVE_MACROS_STRING);
	GetIndString(tempString2,MISC_STRINGS,DEFAULT_MACRO_SET_NAME);

	if (theFile == 0) {
		SFPutFile( where, tempString, tempString2, 0L, &whereReply);

		if (!whereReply.good)
			return;

		BlockMoveData(&whereReply.fName, macroFile.name, (*whereReply.fName)+1); 
		GetWDInfo(whereReply.vRefNum, &macroFile.vRefNum, &macroFile.parID, &junk);
	}
	else
		macroFile = *theFile;

	if ((err = HCreate(macroFile.vRefNum, macroFile.parID, 
			macroFile.name, kNCSACreatorSignature, 'TEXT')) == dupFNErr)
		exist = 1;
	
	err = HOpenDF(macroFile.vRefNum, macroFile.parID, macroFile.name, fsWrPerm, &refNum);

	if (exist) 
		SetEOF(refNum, 0L);

	
	for (i = 0; i < 10; i++)
	{
		oldgetmacro(i, temp, sizeof(temp), 1);
		sprintf(temp2, "key%d = \"", i);
		CStringToFile(refNum,(unsigned char *) temp2);
		if (*temp)
		{
			CStringToFile(refNum,(unsigned char *) temp);
		}
		strcpy(temp2,"\"\015");
		CStringToFile(refNum,(unsigned char *) temp2);

	}
	FSClose(refNum);

}
void QTCmpr_PromptUserForDiskFileAndSaveCompressed (Handle theHandle, ImageDescriptionHandle theDesc)
{
	FSSpec				myFile;
	Boolean				myIsSelected = false;
	Boolean				myIsReplacing = false;	
	short				myRefNum = -1;
	StringPtr 			myImagePrompt = QTUtils_ConvertCToPascalString(kQTCSaveImagePrompt);
	StringPtr 			myImageFileName = QTUtils_ConvertCToPascalString(kQTCSaveImageFileName);
	OSErr				myErr = noErr;

	// do a little parameter checking....
	if ((theHandle == NULL) || (theDesc == NULL))
		goto bail;
		
	if ((**theDesc).dataSize > GetHandleSize(theHandle))
		goto bail;

	// prompt the user for a file to put the compressed image into; in theory, the name
	// should have a file extension appropriate to the type of compressed data selected by the user;
	// this is left as an exercise for the reader
	QTFrame_PutFile(myImagePrompt, myImageFileName, &myFile, &myIsSelected, &myIsReplacing);
	if (!myIsSelected)
		goto bail;

	HLock(theHandle);

	// create and open the file
	myErr = FSpCreate(&myFile, kImageFileCreator, (**theDesc).cType, 0);
	
	if (myErr == noErr)
		myErr = FSpOpenDF(&myFile, fsRdWrPerm, &myRefNum);
		
	if (myErr == noErr)
		myErr = SetFPos(myRefNum, fsFromStart, 0);

	// now write the data in theHandle into the file
	if (myErr == noErr)
		myErr = FSWrite(myRefNum, &(**theDesc).dataSize, *theHandle);
	
	if (myErr == noErr)
		myErr = SetFPos(myRefNum, fsFromStart, (**theDesc).dataSize);

	if (myErr == noErr)
		myErr = SetEOF(myRefNum, (**theDesc).dataSize);
				 
	if (myRefNum != -1)
		myErr = FSClose(myRefNum);
		
bail:
	free(myImagePrompt);
	free(myImageFileName);

	HUnlock(theHandle);
}
Exemple #26
0
void start_data_dump()
{
	short i;
	char get_text[280];
	FILE *data_dump_file_id;
	long len;

	 sprintf(get_text,"%s - Scenario Data.txt",scenario.scen_name);
	if (NULL == (data_dump_file_id = fopen(get_text, "wb"))) {
		oops_error(11);
		return;
		}

	sprintf((char *)get_text,"\r\rScenario data for %s:\r\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	sprintf((char *)get_text,"Floor types for %s:\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	for (i = 0; i < 256; i++) {
			sprintf((char *)get_text,"  Floor %d: \t%s\r",(int)i,scen_data.scen_floors[i].floor_name);
			len = (long) (strlen((char *)get_text));
			FSWrite(data_dump_file_id, &len, (char *) get_text);
			}
	sprintf((char *)get_text,"\r\rTerrain types for %s:\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	for (i = 0; i < 512; i++) {
			sprintf((char *)get_text,"  Terrain %d: \t%s\r", (int)i,scen_data.scen_ter_types[i].ter_name);
			len = (long) (strlen((char *)get_text));
			FSWrite(data_dump_file_id, &len, (char *) get_text);
			}
	sprintf((char *)get_text,"\r\rCreature types for %s:\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	for (i = 0; i < 256; i++) {
		sprintf((char *)get_text,"  Creature %d: \t%s\r",(int)i,scen_data.scen_creatures[i].name);
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
		}
	sprintf((char *)get_text,"\r\rItem types for %s:\r",scenario.scen_name);
	len = (long) (strlen((char *)get_text));
	FSWrite(data_dump_file_id, &len, (char *) get_text);
	for (i = 0; i < NUM_SCEN_ITEMS; i++) {
		sprintf((char *)get_text,"  Item %d: \t%s\r", (int)i,scen_data.scen_items[i].full_name);
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
		}
		sprintf((char *)get_text,"\r\r");
		len = (long) (strlen((char *)get_text));
		FSWrite(data_dump_file_id, &len, (char *) get_text);
	FSClose(data_dump_file_id);
}	
Exemple #27
0
void *__PHYSFS_platformOpenAppend(const char *filename)
{
    SInt16 *retval = macDoOpen(filename, fsRdWrPerm, 1);
    if (retval != NULL)   /* got a file; seek to end. */
    {
        if (oserr(SetFPos(*retval, fsFromLEOF, 0)) != noErr)
        {
            FSClose(*retval);
            return(NULL);
        } /* if */
    } /* if */

    return(retval);
} /* __PHYSFS_platformOpenAppend */
Exemple #28
0
OSErr PAS_decodeData(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
	OSErr 		err;	
	short		outRefNum;
	Ptr 		buffer;
	SInt32 		currentWrite = 	PAS_BUFFER_SIZE;
	SInt32		totalSize;
	
	
	buffer = NewPtr(currentWrite);
	
	
	err = FSpOpenDF(outFile, fsRdWrPerm, &outRefNum);
	if (err != noErr)	return err;
	
	
	err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
	if (err != noErr)	return err;
	
	err = SetFPos(outRefNum, fsFromStart, 0 );
	if (err != noErr)	return err;
	
	totalSize = (*entry).entryLength;
	
	while(totalSize > 0)
	{	
		currentWrite = PAS_BUFFER_SIZE;

		if (totalSize < currentWrite)
		{
			currentWrite = totalSize;
		}

		err	= FSRead( inRefNum, &currentWrite, buffer);
		if (err != noErr && err != eofErr)	return err;
	
		err = FSWrite(outRefNum, &currentWrite, buffer);
		if (err != noErr)	return err;
		
		totalSize = totalSize - currentWrite;

	}
	
	FSClose(outRefNum);
	
	DisposePtr(buffer);
	
	return noErr;

}
Exemple #29
-1
A0(PUBLIC, LONGINT, ROMlib_ZeroScrap)
{
    OSErr retval;
    INTEGER f;
    THz saveZone;
    
    if (Cx(ScrapState) < 0) {
        ScrapCount = 0;
	saveZone = TheZone;
	TheZone = SysZone;
        ScrapHandle = RM(NewHandle((Size)0));
	TheZone = saveZone;
        ScrapState = CWC (1);
        ScrapName = RM((StringPtr) "\016Clipboard File");
    } else if (Cx(ScrapState) == 0) {
        retval = cropen(&f);
        if (retval != noErr)
            return retval;
        retval = SetEOF(f, (LONGINT)0);
        if (retval != noErr)
            return retval;
        FSClose(f);
    } else if (Cx(ScrapState) > 0)
        SetHandleSize(MR(ScrapHandle), (Size)0);
    ScrapSize = 0;
    ScrapCount = CW(CW(ScrapCount) + 1);
    return noErr;
}
Exemple #30
-1
P0(PUBLIC pascal trap, LONGINT, LoadScrap)
{
    OSErr retval;
    INTEGER f;
    LONGINT l = Cx(ScrapSize);
    
    if (ScrapState == 0) {
        retval = FSOpen(MR(ScrapName), CW (BootDrive), &f);
        if (retval != noErr)
            return(retval);

        HUnlock(MR(ScrapHandle));
        ReallocHandle(MR(ScrapHandle), (Size)Cx(ScrapSize));
	if (MemErr != noErr)
/*-->*/	    return Cx(MemErr);
        HLock(MR(ScrapHandle));
        retval = FSReadAll(f, &l, STARH(MR(ScrapHandle)));
        HUnlock(MR(ScrapHandle));
        if (retval != noErr)
            return(retval);
        SetEOF(f, (LONGINT) 0);
        FSClose(f);
        ScrapState = CWC (1);
    }
    return(Cx(ScrapState) > 0 ? noErr : noScrapErr);
}