Exemplo n.º 1
0
Arquivo: ugView.c Projeto: rolk/ug
static void PICTCommand (void)
{
  OSErr error ;
  SFReply reply ;
  Point wher ;
  char buffer1[32],buffer2[128];
  char *s;

  if (globalState!=OPENED) return;

  /* get file name */
  wher.v = 40 ;
  wher.h = 40 ;
  strcpy(buffer1,"Name of Pict-File :");
  strcpy(buffer2,fileName);
  if ((s=strstr(buffer2,".meta"))!=NULL)
    *s = '\0';
  strcat(buffer2,".pict");
  SFPutFile ( wher, c2pstr(buffer1), c2pstr(buffer2), NULL, &reply ) ;
  if (!reply.good) return;

  error = Create ( reply.fName, reply.vRefNum, *((OSType *)"DAD2"), *((OSType *)"PICT") ) ;
  if ((error!=noErr) && (error!=dupFNErr))
  {
    OneButtonBox("Could not create file","OK");
    return;
  }

  SaveToPICT(&reply);
  return;
}
Exemplo n.º 2
0
Arquivo: ugView.c Projeto: rolk/ug
static void HDFCommand (void)
{
  SFReply reply;
  Point where;
  char prompt[128];
  OSErr error;
  char buffer[80];
  char *s;

  if (globalState!=OPENED) return;

  /* get file name */
  strcpy(buffer,"Save HDF image as:");
  strcpy(prompt,fileName);
  if ((s=strstr(prompt,".meta"))!=NULL)
    *s = '\0';
  strcat(prompt,".hdf");
  where.h = 20; where.v = 40;
  SFPutFile(where,c2pstr(buffer),c2pstr(prompt),NULL,&reply);
  if (!reply.good) return;

  /* set volume */
  error = SetVol(NULL,reply.vRefNum);
  if (((int)error)!=0)
  {
    OneButtonBox("Could not set volume","OK");
    return;
  }
  /* change pascal string to C string */
  p2cstr(reply.fName);

  RefreshCommand();
  SaveToHDF(reply.fName);
  return;
}
Exemplo n.º 3
0
OSErr choose_new_file(
	short *file_handle,
	short *reference_number,
	char *file_name,
	char *prompt,
	long creator,
	long file_type)
{
	Point location;
	SFReply reply;
	OSErr error;
	
	SetPt(&location, 40, 60);
	SFPutFile(location, prompt, file_name, (DlgHookProcPtr) NULL, &reply);
	if (reply.good)
	{
		error= Create(reply.fName, reply.vRefNum, creator, file_type);
		if (error==dupFNErr||error==noErr)
		{
			strncpy(file_name, reply.fName, *reply.fName+1);
			*reference_number= reply.vRefNum;
			
			error= FSOpen(reply.fName, reply.vRefNum, file_handle);
		}
	}
	else
	{
		error= userCanceledErr;
	}
	
	return error;
}
Exemplo n.º 4
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);

}
Exemplo n.º 5
0
static void CreateAMovie (void)
{
	Point where = {100,100};
	SFReply theSFReply;

	Movie theMovie = nil;
	FSSpec mySpec;
	short resRefNum = 0;
	short resId = movieInDataForkResID;
	OSErr err = noErr;

		SFPutFile (where, c2pstr(kPrompt), 
					c2pstr(kMovieFileName), nil, &theSFReply);
		if (!theSFReply.good) return; 

		FSMakeFSSpec(theSFReply.vRefNum, 0, theSFReply.fName, &mySpec);


		err = CreateMovieFile (&mySpec, 
							kMyCreatorType,
							smCurrentScript, 
							createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
							&resRefNum, 
							&theMovie );
		CheckError(err, "CreateMovieFile error");

		QTVideo_CreateMyVideoTrack (theMovie);
		QTSound_CreateMySoundTrack (theMovie);


		err = AddMovieResource (theMovie, resRefNum, &resId,
		 						theSFReply.fName);
		CheckError(err, "AddMovieResource error");

		if (resRefNum)

		{

			CloseMovieFile (resRefNum);

		}
		DisposeMovie (theMovie);
} 
Exemplo n.º 6
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);
}