home *** CD-ROM | disk | FTP | other *** search
- /* This file contains calls to standard file along with file opens */
- /*
- Author: Jerry LeVan
- 325 Boone Trail
- Richmond Ky 40475
- */
- #include <packages.h>
- #include <files.h>
- #include <errors.h>
-
- Boolean OkToSendFile(fref)
- short *fref; /* channel if all goes well */
- {
- Point loc;
- SFTypeList typeList;
- SFReply reply;
- short ntypes;
- short err;
-
- loc.v = 80;
- loc.h = 100;
- ntypes = 1;
-
- typeList[0] = 'TEXT';
-
- SFGetFile(&loc, 0, 0, ntypes, typeList, 0, &reply);
-
- if( reply.good ){
- p2cstr(&reply.fName); /* fix for further high level calls */
- /* now try the open */
- if(err = FSOpen(&reply.fName,reply.vRefNum,fref)){
- ErrorMessage("Can't Open Text File",err);
- return false;}
- return true;
- }
- else return false;
- }
-
- Boolean OkToReceiveFile(fref,vref,creator)
- short *fref; /* returned channel */
- short *vref; /* volume ref for flush */
- OSType creator;
- {
- SFReply reply;
- Point loc;
- short err;
-
- loc.v = 80;
- loc.h = 100;
-
- SFPutFile(&loc, "Select Name","ReceiveFile.Txt", nil, &reply);
- if(reply.good){
- p2cstr(&reply.fName); /* convert to c string */
- if(err=Create(&reply.fName,reply.vRefNum,creator,'TEXT'))
- if(err!=dupFNErr){
- ErrorMessage("Can't Create Text File",err);
- return false;}
-
- if(err = FSOpen(&reply.fName,reply.vRefNum,fref)){
- ErrorMessage("Can't Open Text File",err);
- return false;}
-
- /* truncate the file in case it already exists */
- if(err=SetEOF(*fref,0)){
- ErrorMessage("Error Truncating File",err);
- return false;}
-
- /* everything is ok if we get here */
- *vref = reply.vRefNum; /* the open fixed the channel */
- return true;
- }
- return false;
- }
-
-