Beispiel #1
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);
}	
Beispiel #2
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);
}	
Beispiel #3
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);
}	
Beispiel #4
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);
}	
Beispiel #5
0
Datei: ugView.c Projekt: 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;
}
Beispiel #6
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);
}	
Beispiel #7
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;
}
Beispiel #8
0
void
XMLMacCarbonFile::write(const long byteCount, const XMLByte* const buffer)
{
    long bytesWritten = 0;
    OSErr err = noErr;

    if (byteCount <= 0 || buffer == NULL)
        return;

    if (!mFileValid)
    {
        ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile);
    }

    if (gHasHFSPlusAPIs)
    {
        ByteCount actualCount;
        err = FSWriteFork(mFileRefNum, fsFromMark, 0, byteCount, buffer, &actualCount);
        bytesWritten = actualCount;
    }
    else
    {
        long count = byteCount;
        err = FSWrite(mFileRefNum, &count, buffer);
        bytesWritten = count;
    }

    if ((err != noErr && err != eofErr) || (bytesWritten != byteCount))
    {
        ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile);
    }
}
/*__________________________________________________________________________*/
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;
}
Beispiel #10
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;
}
Beispiel #11
0
int ndiSerialWrite(long serial_port, const char *text, int n)
{
  if (FSWrite(output_file(serial_port),&n,text) != noErr) {
    return -1;
  }
  
  return n;
}
OSErr WriteObjectInfo (short FRefNum, ObjectRecHdl thisObjectHdl)
{
	OSErr	ErrCode = 0;
	long	byteCount, structSize;

	// write the size of this object
	structSize = _GetHandleSize ((Handle) thisObjectHdl);
	byteCount = sizeof (long);
	ErrCode = FSWrite (FRefNum, &byteCount, (Ptr) &structSize);

	if (!ErrCode)
	{	
		_HLock ((Handle) thisObjectHdl);
		
		ErrCode = FSWrite (FRefNum, &structSize, (Ptr) *thisObjectHdl);
		
		_HUnlock ((Handle) thisObjectHdl);

		if (!ErrCode)	// write the contents of the data handle if necessary
		{
			Handle	thisObjectDataHdl;
			
			thisObjectDataHdl = GetObjectDataHdl (thisObjectHdl);
			if (thisObjectDataHdl != nil)
			{
				// write the size of the data handle first
				structSize = _GetHandleSize (thisObjectDataHdl);
				byteCount = sizeof (long);
				ErrCode = FSWrite (FRefNum, &byteCount, (Ptr) &structSize);
			
				if (!ErrCode)
				{
					_HLock ((Handle) thisObjectDataHdl);
					
					ErrCode = FSWrite (FRefNum, &structSize, (Ptr) *thisObjectDataHdl);
					
					_HUnlock ((Handle) thisObjectDataHdl);
				}
			}
		}
	}
	
	return (ErrCode);
}
Beispiel #13
0
/* デバッグファイルに文字列を出力 */
void WriteStrToDebugFile(Str255 str)
{
	OSErr	err;
	long	count;
	
	if (debugFileRefNum<=0) return;
	
	count=*str;
	err=FSWrite(debugFileRefNum,&count,str+1);
}
Beispiel #14
0
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
                                     PHYSFS_uint32 size, PHYSFS_uint32 count)
{
    SInt16 ref = *((SInt16 *) opaque);
    SInt32 bw = size*count;

	BAIL_IF_MACRO(oserr(FSWrite(ref, &bw, buffer)) != noErr, NULL, bw/size);
	BAIL_IF_MACRO(bw != size*count, NULL, bw/size); /* !!! FIXME: seek back if only wrote part of an object! */

    return(count);
} /* __PHYSFS_platformWrite */
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);
}
Beispiel #16
0
Datei: ugView.c Projekt: rolk/ug
static pascal void MyPutPicData ( void            *Data_Ptr ,
                                  short ByteCount )
{
  long LongCount ;
  OSErr error;

  LongCount  = ByteCount ;
  PicCounter = PicCounter + ByteCount ;
  error          = FSWrite ( FileSys_RefNR, &LongCount, Data_Ptr ) ;
  if (MyPicHand != NULL)
    (**MyPicHand).picSize = PicCounter ;
}  /* MyPutPicData */
Beispiel #17
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;

}
Beispiel #18
0
write_backing_store (j_common_ptr cinfo, backing_store_ptr info,
                     void FAR * buffer_address,
                     long file_offset, long byte_count)
{
  long bytes = byte_count;
  long retVal;

  if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr )
    ERREXIT(cinfo, JERR_TFILE_SEEK);

  retVal = FSWrite ( info->temp_file, &bytes,
                     (unsigned char *) buffer_address );
  if ( retVal != noErr || bytes != byte_count )
    ERREXIT(cinfo, JERR_TFILE_WRITE);
}
Beispiel #19
0
UINT file_write(FILEH handle, const void *data, UINT length) {

	if (length) {
		long size = length;
		if (FSWrite(handle, &size, (char *)data) == noErr) {
			return(size);
		}
	}
	else {
		SInt32 pos;
		if (GetFPos(handle, &pos) == noErr) {
			SetEOF(handle, pos);
		}
	}
	return(0);
}
Beispiel #20
0
OSErr PAS_encodeResource(FSSpec *inFile, short outRefNum)
{
	OSErr 			err;	
	short			inRefNum;
	PASResFork		resInfo;
	SInt32			currentWrite;
	
	ResType 		*resTypes;
	long			typeCount;
	
	short			*ids;
	long			idCount;
	
	short			oldResFile;
	
	oldResFile=CurResFile();
	inRefNum = FSpOpenResFile(inFile, fsRdPerm);
	if (inRefNum < noErr)	return inRefNum;

	UseResFile(inRefNum);
		
	memset(&resInfo, 0, sizeof(PASResFork));   
	
	PAS_sortTypes(inRefNum, &resTypes, &typeCount);

	resInfo.NumberOfTypes	=	typeCount;
	
	currentWrite	= sizeof(PASResFork);
	
	err = FSWrite(outRefNum, &currentWrite, &resInfo);
	if (err != noErr)	return err;
	
	for (typeCount = 0; ((typeCount < resInfo.NumberOfTypes) && (err == noErr)); typeCount++)
	{
		PAS_sortIDs(inRefNum, resTypes[typeCount], &ids, &idCount);
		err = PAS_flattenResource(resTypes[typeCount], ids, idCount, inRefNum, outRefNum);
		DisposePtr((Ptr)ids);
	}
	
	DisposePtr((Ptr)resTypes);
	
	
	UseResFile(oldResFile);		
	CloseResFile(inRefNum);
	
	return err;
}
Beispiel #21
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;
}
EXPORT (int) serialPortWriteFrom(int portNum, int count, void *bufferPtr) {
/* Write count bytes from the given byte array to the given serial port's
   output buffer. Return the number of bytes written. This implementation is
   synchronous: it doesn't return until the data has been sent. However, other
   implementations may return before transmission is complete. */

	long int byteCount = count;
	int osErr;

	if (!serialPortIsOpen(portNum)) {
		return interpreterProxy->success(false);
	}

	osErr = FSWrite(outRefNum[portNum], &byteCount, (char *) bufferPtr);
	if (osErr != noErr) {
		return interpreterProxy->success(false);
	}
	return byteCount;
}
Beispiel #23
0
OSErr PAS_encodeHeader(short refnum)
{
	PASHeader 	header;
	long		sizeOfHeader;
	OSErr		err;
	
	
	sizeOfHeader = sizeof(PASHeader);
		
	memset(&header, 0, sizeOfHeader);   
	
	header.magicNum 	= PAS_MAGIC_NUM;
	header.versionNum 	= PAS_VERSION;
	header.numEntries 	= 3;
	
	/* Write Out Header */
	err = FSWrite(refnum, &sizeOfHeader, &header);
	
	return err;

}
Beispiel #24
0
static void
FlushWinFile (void)
{
	short ref;
	long len;

	if (!winFileInit) {
		if (!winFileName [0]) {
			return;
		}
		HCreate (winFileVol, winFileDir, winFileName, MAC_CREATOR, PREF_TYPE);
		HCreateResFile (winFileVol, winFileDir, winFileName);
	}
	if (HOpen (winFileVol, winFileDir, winFileName, fsWrPerm, &ref)) {
		return;
	}
	winFileInit = 1;
	len = sizeof (savePos);
	(void) FSWrite (ref, &len, savePos); /* Don't care about error */
	FSClose (ref);
}
Beispiel #25
0
/* create icns(icon for MacOS X) with IPIcon */
OSErr MakeXIconWithIPIcon(const FSSpec *theFile,const IPIconRec *ipIcon)
{
	OSErr	err;
	FInfo	fndrInfo;
	short	refNum;
	IconFamilyHandle	iconFamily;
	long	count;
	
	if (!isIconServicesAvailable) return -1;
	
	/* convert IPIcon to icns */
	err=IPIconToIconFamily(ipIcon,&iconFamily);
	if (err!=noErr) return err;
	
	/* create a file */
	err=FSpGetFInfo(theFile,&fndrInfo);
	if (err==fnfErr)
		err=FSpCreate(theFile,kIconPartyCreator,kXIconFileType,smSystemScript);
	if (err!=noErr) return err;
	
	/* open the file */
	err=FSpOpenDF(theFile,fsWrPerm,&refNum);
	if (err!=noErr) return err;
	
	/* save icns */
	HLock((Handle)iconFamily);
	count=GetHandleSize((Handle)iconFamily);
	err=FSWrite(refNum,&count,*iconFamily);
	err=SetEOF(refNum,count);
	HUnlock((Handle)iconFamily);
	DisposeHandle((Handle)iconFamily);
	
	/* close the file */
	err=FSClose(refNum);
	
	return noErr;
}
Beispiel #26
0
void saveMacros(NewMacroInfo *macrost, FSSpec *theFile)
{
	SFReply		whereReply;
	short 		refNum,exist;
	FSSpec		macroFile;
	long		junk, len, len2;
	short 		i;
	Point		where;
	OSErr		err;
	Str255		tempString,tempString2;
	Handle		macroHandle;
	Ptr			pos;

	if (!macrost->handle) return; // sanity check

	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);

// the new code - RAB BetterTelnet 2.0b5
	macroHandle = macrost->handle;
	HandToHand(&macroHandle);
	HLock(macroHandle);
	pos = *macroHandle;
	len = len2 = GetHandleSize(macroHandle);
	while (len) {
		if (*pos == 0) *pos = 13;
		pos++;
		len--;
	}

	pos = *macroHandle;
	junk = 2;
	FSWrite(refNum, &junk, "!\015");
	FSWrite(refNum, &len2, pos);
	DisposeHandle(macroHandle); // it's a copy anyway, get rid of it!

	FSClose(refNum);
}
Beispiel #27
0
OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, short dest)
{
	long 			idIndex;
	
	
	Handle			resToCopy;
	long			handleLength;
	
	PASResource		pasResource;
	long			pasResLen;
	
	OSErr			err;
	
	for (idIndex=0; idIndex < count; idIndex++)
	{
		if( (type == 'SIZE') && ( ids[idIndex] == 1 || ids[idIndex] == 0  ) )
		{
			/* 	
				We do not want to encode/flatten SIZE 0 or 1 because this
				is the resource that the user can modify.  Most applications
				will not be affected if we remove these resources
			*/
		}
		else
		{	
			resToCopy=Get1Resource(type,ids[idIndex]);
					
			if(!resToCopy)	
			{
				return resNotFound;
			}	
				
			memset(&pasResource, 0, sizeof(PASResource));	
				
			GetResInfo(	resToCopy, 	
						&pasResource.attrID, 
						&pasResource.attrType, 
						pasResource.attrName);	
			
			pasResource.attr = GetResAttrs(resToCopy);
			
			DetachResource(resToCopy);	
			HLock(resToCopy);
			
			pasResource.length 	= GetHandleSize(resToCopy);
			handleLength 		= pasResource.length;
			
			pasResLen			=	sizeof(PASResource);
			
			err = FSWrite(dest, &pasResLen, &pasResource);
			
			if(err != noErr) 
			{
				return err;
			}
			
			err = FSWrite(dest, &handleLength, &(**resToCopy));

			if(err != noErr) 
			{
				return err;
			}
			
			HUnlock(resToCopy);
			DisposeHandle(resToCopy);		
		}
	}
	
	
	return noErr;
}
Beispiel #28
0
OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec)
{
	OSErr		err;
	short		outRefNum;
	
	PASEntry 	dataEntry, miscEntry, resourceEntry;
	long		sizeOfEntry;


	if (inSpec == NULL || outSpec == NULL)
		return paramErr;
		

	memset(&dataEntry, 0, sizeof(PASEntry));
	memset(&miscEntry, 0, sizeof(PASEntry));
	memset(&resourceEntry, 0, sizeof(PASEntry));
	
	FSpDelete( outSpec ) ;
	
	err = FSpCreate( outSpec, kCreator, kType ,smSystemScript );
	
	if (err != noErr) 	return err;
	
	
	err = FSpOpenDF(outSpec, fsRdWrPerm, &outRefNum);
	
	if (err != noErr)  goto error;
	

	/* Write Out Header */
		
	err = PAS_encodeHeader(outRefNum);
	if (err != noErr)  goto error;
	
	/* Why am I using three (3)?
		
		E stand for entry.
		
	   The data for the entry is after the THREE headers 
	
		|---------|----|----|----|---------------------->
		   header    E    E    E
	
	*/
	
	
	/* Write Out Data Entry */
	dataEntry.entryID		=	ePas_Data;
	dataEntry.entryLength	=	PAS_getDataSize(inSpec);
	dataEntry.entryOffset	=	sizeof(PASHeader) + (3 * sizeof(PASEntry));
	
	sizeOfEntry			=	sizeof(PASEntry);
	if(dataEntry.entryLength < 0)
	{
		err	= dataEntry.entryLength;
		goto error;
	}
	
	err = FSWrite(outRefNum, &sizeOfEntry, &dataEntry);
	if (err != noErr) 	goto error;
	
	
	
	/* Write Out Misc Entry */
	miscEntry.entryID		=	ePas_Misc;
	miscEntry.entryLength	=	sizeof(PASMiscInfo);
	miscEntry.entryOffset	=	sizeof(PASHeader) + (3 * sizeof(PASEntry)) + dataEntry.entryLength;

	sizeOfEntry			=	sizeof(PASEntry);
	err = FSWrite(outRefNum, &sizeOfEntry, &miscEntry);
	if (err != noErr) 	goto error;
	
	
	/* Write Out Resource Entry */
	resourceEntry.entryID		=	ePas_Resource;
	resourceEntry.entryLength	=	-1;
	resourceEntry.entryOffset	=	sizeof(PASHeader) + (3 * sizeof(PASEntry)) + dataEntry.entryLength + miscEntry.entryLength;


	sizeOfEntry			=	sizeof(PASEntry);
	err = FSWrite(outRefNum, &sizeOfEntry, &resourceEntry);
	if (err != noErr) 	goto error;
	
	err =  PAS_encodeData(inSpec, outRefNum);	
	if (err != noErr) 	goto error;
	
	
	err =  PAS_encodeMisc(inSpec, outRefNum);	
	if (err != noErr) 	goto error;
	
	err =  PAS_encodeResource(inSpec, outRefNum);	
	
	if (err == kResFileNotOpened)
	{
		// there was no resource fork
		err = noErr;
	}
	else if (err != noErr)
	{
		goto error;
	}
		
	FSClose(outRefNum);
	
	return noErr;
	
	
	
error:
		
		
	if (outRefNum != kResFileNotOpened)
	{
		FSClose(outRefNum);
	}
		
	FSpDelete( outSpec ) ;
	 
	return err;

}
Beispiel #29
0
static tsize_t
_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
{
	return (FSWrite((short) fd, (long*) &size, (char*) buf) == noErr ?
	    size : (tsize_t) -1);
}
Beispiel #30
0
OSErr QTInfo_MakeFilePreview (Movie theMovie, short theRefNum, ICMProgressProcRecordPtr theProgressProc)
{
    unsigned long			myModDate;
    PreviewResourceRecord	myPNOTRecord;
    long					myEOF;
    long					mySize;
    unsigned long			myAtomHeader[2];	// an atom header: size and type
    OSType					myPreviewType;
    OSErr					myErr = noErr;

    //////////
    //
    // determine whether theRefNum is a file reference number of a data fork or a resource fork;
    // if it's a resource fork, then we'll just call the existing ICM function MakeFilePreview
    //
    //////////

    if (QTInfo_IsRefNumOfResourceFork(theRefNum)) {
        myErr = MakeFilePreview(theRefNum, theProgressProc);
        goto bail;
    }

    //////////
    //
    // determine the preview type
    //
    //////////

    // if the movie has a movie preview, use that as the file preview; otherwise use a thumbnail
    // of the movie poster frame as the file preview
    if (QTInfo_MovieHasPreview(theMovie))
        myPreviewType = MovieAID;
    else
        myPreviewType = kQTFileTypePicture;

    //////////
    //
    // construct the 'pnot' atom
    //
    //////////

    // fill in the 'pnot' atom header
    myAtomHeader[0] = EndianU32_NtoB(sizeof(myAtomHeader) + sizeof(myPNOTRecord));
    myAtomHeader[1] = EndianU32_NtoB(ShowFilePreviewComponentType);

    // fill in the 'pnot' atom data
    GetDateTime(&myModDate);

    myPNOTRecord.modDate = EndianU32_NtoB(myModDate);		// the modification time of the preview
    myPNOTRecord.version = EndianS16_NtoB(0);				// version number; must be 0
    myPNOTRecord.resType = EndianU32_NtoB(myPreviewType);	// atom type containing preview
    myPNOTRecord.resID = EndianS16_NtoB(1);					// the 1-based index of the atom of the specified type to use

    //////////
    //
    // write the 'pnot' atom at the end of the data fork
    //
    //////////

    // get the current logical end-of-file and extend it by the desired amount
    myErr = GetEOF(theRefNum, &myEOF);
    if (myErr != noErr)
        goto bail;

    myErr = SetEOF(theRefNum, myEOF + sizeof(myAtomHeader) + sizeof(myPNOTRecord));
    if (myErr != noErr)
        goto bail;

    // set the file mark
    myErr = SetFPos(theRefNum, fsFromStart, myEOF);
    if (myErr != noErr)
        goto bail;

    // write the atom header into the file
    mySize = sizeof(myAtomHeader);
    myErr = FSWrite(theRefNum, &mySize, myAtomHeader);
    if (myErr != noErr)
        goto bail;

    // write the atom data into the file
    mySize = sizeof(myPNOTRecord);
    myErr = FSWrite(theRefNum, &mySize, &myPNOTRecord);
    if (myErr != noErr)
        goto bail;

    //////////
    //
    // write the preview data atom at the end of the data fork
    //
    //////////

    if (myPreviewType == MovieAID) {
        // in theory, we don't need to do anything here, since our 'pnot' atom points
        // to the 'moov' atom; in practice, this doesn't work correctly (it seems like
        // a bug in StandardGetFilePreview)
    }

    if (myPreviewType == kQTFileTypePicture) {
        PicHandle		myPicture = NULL;
        PicHandle		myThumbnail = NULL;

        // get the poster frame picture
        myPicture = GetMoviePosterPict(theMovie);
        if (myPicture != NULL) {

            // create a thumbnail
            myThumbnail = (PicHandle)NewHandleClear(4);
            if (myThumbnail != NULL) {
                myErr = MakeThumbnailFromPicture(myPicture, 0, myThumbnail, theProgressProc);
                if (myErr == noErr) {

                    myAtomHeader[0] = EndianU32_NtoB(sizeof(myAtomHeader) + GetHandleSize((Handle)myThumbnail));
                    myAtomHeader[1] = EndianU32_NtoB(myPreviewType);

                    // write the atom header into the file
                    mySize = sizeof(myAtomHeader);
                    myErr = FSWrite(theRefNum, &mySize, myAtomHeader);
                    if (myErr == noErr) {
                        // write the atom data into the file
                        mySize = GetHandleSize((Handle)myThumbnail);
                        myErr = FSWrite(theRefNum, &mySize, *myThumbnail);
                    }
                }

                KillPicture(myThumbnail);
            }

            KillPicture(myPicture);
        }
    }

#if 0
    // here's how you'd add a text preview; note that the text is hard-coded here....
    if (myPreviewType == kQTFileTypeText) {
        char 	myText[] = "The penguin gradually appears from the mist of the ice floe.";

        myAtomHeader[0] = EndianU32_NtoB(sizeof(myAtomHeader) + strlen(myText));
        myAtomHeader[1] = EndianU32_NtoB(myPreviewType);

        // write the atom header into the file
        mySize = sizeof(myAtomHeader);
        myErr = FSWrite(theRefNum, &mySize, myAtomHeader);
        if (myErr != noErr)
            goto bail;

        // write the atom data into the file
        mySize = strlen(myText);
        myErr = FSWrite(theRefNum, &mySize, myText);
        if (myErr != noErr)
            goto bail;
    }
#endif

#if TARGET_OS_MAC
    if (myErr == noErr) {
        short				myVolNum;

        // flush the volume
        myErr = GetVRefNum(theRefNum, &myVolNum);
        if (myErr != noErr)
            goto bail;

        myErr = FlushVol(NULL, myVolNum);
    }
#endif

bail:
    return(myErr);
}