home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Snippets / binhex / files.c < prev   
Encoding:
C/C++ Source or Header  |  1994-05-03  |  52.6 KB  |  2,611 lines  |  [TEXT/KAHL]

  1. #include "rnmac.h"
  2. #include <Aliases.h>
  3.  
  4. #define customGetDLOG    140
  5.  
  6. #define    SEQF            "SEQUENCEFILE"
  7. #define CREATORSETTING    "TEXTCREATOR"
  8. #define TYPESETTING        "TEXTTYPE"
  9.  
  10.  
  11. static char        *separatorString = "\r\r----\r\r";
  12.  
  13.  
  14.  
  15.  
  16. static int createFolder(char *theSTRName,char *didCreate);
  17.  
  18.  
  19.  
  20. static void GetCreatorType(long *theCreator,long *theType)
  21. {
  22. int        errCode,i;
  23. char    tempString[256];
  24.  
  25.  
  26.     *theCreator = CREATOR;
  27.     *theType = 'TEXT';
  28.  
  29.     if ((errCode = LoadSTRResource(CREATORSETTING,tempString)) == noErr)
  30.     {
  31.         *theCreator = *((long *) tempString);
  32.     }
  33.     
  34.     if ((errCode = LoadSTRResource(TYPESETTING,tempString)) == noErr)
  35.     {
  36.         *theType = *((long *) tempString);
  37.     }
  38. }
  39.  
  40.  
  41. int MyOpenResFile(char *resFileName,int *theFRefNum)
  42. {
  43. FSSpec        theSpec;
  44. char        targetIsFolder,wasAliased;
  45. int            errCode;
  46.  
  47.     *theFRefNum = -1;
  48.     
  49.     errCode = noErr;
  50.     
  51.     if (!hasSys7Aliases)
  52.     {
  53.         *theFRefNum = OpenResFile(StripAddress(resFileName));
  54.         
  55.         if (*theFRefNum == -1)
  56.         {
  57.             errCode = ResError();
  58.             
  59.             PtoCstr(resFileName);
  60.             sprintf(errorMessage,"MyOpenResFile: OpenResFile(%s) error %d",resFileName,errCode);
  61.             CtoPstr(resFileName);
  62.         }
  63.     }
  64.     
  65.     else
  66.     {
  67.         if ((errCode = FSMakeFSSpec(vRefNum,0,resFileName,&theSpec)) != noErr)
  68.         {
  69.             PtoCstr(resFileName);
  70.             sprintf(errorMessage,"MyOpenResFile: FSMakeFSSpec(%s) error %d",resFileName,errCode);
  71.             CtoPstr(resFileName);
  72.             goto EXITPOINT;
  73.         }
  74.         
  75.         
  76.         if ((errCode = ResolveAliasFile(&theSpec,TRUE,(Boolean *) &targetIsFolder,(Boolean *) &wasAliased)) != noErr)
  77.         {
  78.             PtoCstr(resFileName);
  79.             sprintf(errorMessage,"MyOpenResFile: ResolveAliasFile(%s) error %d",resFileName,errCode);
  80.             CtoPstr(resFileName);
  81.             goto EXITPOINT;
  82.         }
  83.         
  84.         if (targetIsFolder)
  85.         {
  86.             errCode = -1;
  87.             PtoCstr(resFileName);
  88.             sprintf(errorMessage,"MyOpenResFile: attempt to open aliased file '%s' which resolves to a folder, not a file",resFileName);
  89.             CtoPstr(resFileName);
  90.             goto EXITPOINT;
  91.         }
  92.         
  93.         *theFRefNum = FSpOpenResFile(&theSpec,0);
  94.         
  95.         if (*theFRefNum == -1)
  96.         {
  97.             errCode = ResError();
  98.             
  99.             PtoCstr(resFileName);
  100.             sprintf(errorMessage,"MyOpenResFile: FSpOpenResFile(%s) error %d",resFileName,errCode);
  101.             CtoPstr(resFileName);
  102.         }
  103.     }
  104.  
  105. EXITPOINT:
  106.     
  107.     return(errCode);
  108. }
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. int MyOpenResFile67SF(sys67SFReply *thesys67SFReply,int *theFRefNum)
  116. {
  117. int            errCode,currentVol;
  118. char        tempString[256];
  119.  
  120.     *theFRefNum = -1;
  121.     
  122.     errCode = noErr;
  123.     
  124.     if (!hasSys7Aliases)
  125.     {
  126.         errCode = GetVol(tempString,¤tVol);
  127.         
  128.         if (errCode != noErr)
  129.         {
  130.             sprintf(errorMessage,"MyOpenResFile67SF: GetVol() error %d",errCode);
  131.             goto EXITPOINT;
  132.         }
  133.         
  134.         errCode = SetVol(0L,thesys67SFReply->sys6SFReply.vRefNum);
  135.         
  136.         if (errCode != noErr)
  137.         {
  138.             sprintf(errorMessage,"MyOpenResFile67SF: SetVol(%d) error %d",(int) (thesys67SFReply->sys6SFReply.vRefNum),errCode);
  139.             
  140.             goto EXITPOINT;
  141.         }
  142.         
  143.         
  144.         *theFRefNum = OpenResFile(StripAddress(thesys67SFReply->sys6SFReply.fName));
  145.         
  146.         
  147.         if (*theFRefNum == -1)
  148.         {
  149.             errCode = ResError();
  150.             
  151.             PtoCstr(thesys67SFReply->sys6SFReply.fName);
  152.             sprintf(errorMessage,"MyOpenResFile67SF: OpenResFile(%s) error %d",thesys67SFReply->sys6SFReply.fName,errCode);
  153.             CtoPstr(thesys67SFReply->sys6SFReply.fName);
  154.         }
  155.         
  156.         SetVol(0L,currentVol);
  157.     }
  158.     
  159.     else
  160.     {
  161.         *theFRefNum = FSpOpenResFile(&(thesys67SFReply->sys7SFReply.sfFile),0);
  162.         
  163.         if (*theFRefNum == -1)
  164.         {
  165.             errCode = ResError();
  166.             
  167.             PtoCstr(thesys67SFReply->sys7SFReply.sfFile.name);
  168.             sprintf(errorMessage,"MyOpenResFile67SF: FSpOpenResFile(%s) error %d",thesys67SFReply->sys7SFReply.sfFile.name,errCode);
  169.             CtoPstr(thesys67SFReply->sys7SFReply.sfFile.name);
  170.         }
  171.     }
  172.  
  173. EXITPOINT:
  174.     
  175.     return(errCode);
  176. }
  177.  
  178.  
  179.  
  180.  
  181. int BuildPathName(char *fName,int theVRefNum,long dirID,char *thePath)
  182. {
  183. CInfoPBRec    theCPB;
  184. char        tempString[256];
  185. int            errCode;
  186. long        currentDirID;
  187.  
  188.     strcpy(thePath,fName);
  189.     
  190.     tempString[0] = 0;
  191.     currentDirID = dirID;
  192.     
  193.     do
  194.     {
  195.         theCPB.dirInfo.ioCompletion = 0L;
  196.         theCPB.dirInfo.ioNamePtr = (StringPtr) tempString;
  197.         theCPB.dirInfo.ioVRefNum = theVRefNum;
  198.         theCPB.dirInfo.ioFDirIndex = -1;
  199.         theCPB.dirInfo.ioDrDirID = currentDirID;
  200.         
  201.         if ((errCode = PBGetCatInfo(&theCPB,FALSE)) != noErr)
  202.         {
  203.             sprintf(errorMessage,"BuildPathName: PBGetCatInfo(%s) error %d",fName,errCode);
  204.             thePath[0] = 0;
  205.             return(errCode);
  206.         }
  207.         
  208.         PtoCstr(tempString);
  209.         mystrncat(tempString,":",255);
  210.         mystrncat(tempString,thePath,255);
  211.         mystrncpy(thePath,tempString,255);
  212.         
  213.         currentDirID = theCPB.dirInfo.ioDrParID;
  214.     
  215.     } while (currentDirID > 1);
  216.     
  217.     return(noErr);
  218. }
  219.  
  220.  
  221.  
  222.  
  223. int ResolveAndBuildAliasPathName(char *fName,int theVRefNum,char *thePath)
  224. {
  225. FSSpec        theSpec;
  226. int            errCode;
  227. char        targetIsFolder,wasAliased;
  228. char        cFilename[256];
  229.  
  230.     errCode = noErr;
  231.     thePath[0] = 0;
  232.     
  233.     PtoCstr(fName);
  234.     mystrncpy(cFilename,fName,255);
  235.     CtoPstr(fName);
  236.     
  237.     if (!hasSys7Aliases)
  238.     {
  239.         errCode = BuildPathName(fName,theVRefNum,0L,thePath);
  240.     }
  241.     
  242.     else
  243.     {
  244.         if ((errCode = FSMakeFSSpec(theVRefNum,0,fName,&theSpec)) != noErr)
  245.         {
  246.             sprintf(errorMessage,"ResolveAndBuildAliasPathName: FSMakeFSSpec(%s) error %d",cFilename,errCode);
  247.         }
  248.         
  249.         else
  250.         {
  251.             errCode = ResolveAliasFile(&theSpec,TRUE,(Boolean *) &targetIsFolder,(Boolean *) &wasAliased);
  252.             
  253.             if (errCode != noErr && errCode != fnfErr)
  254.             {
  255.                 sprintf(errorMessage,"ResolveAndBuildAliasPathName: ResolveAliasFile(%s) error %d",cFilename,errCode);
  256.             }
  257.             
  258.             else
  259.             {
  260.                 PtoCstr((char *) theSpec.name);
  261.                 
  262.                 errCode = BuildPathName((char *) theSpec.name,theSpec.vRefNum,theSpec.parID,thePath);
  263.             }
  264.         }
  265.     }
  266.     
  267.     return(errCode);
  268. }
  269.  
  270.  
  271.  
  272.  
  273.  
  274. int MyFSOpen(char *fName,int vRefNum,int *fRefNum)
  275. {
  276. FSSpec        theSpec;
  277. char        targetIsFolder,wasAliased;
  278. int            errCode;
  279.  
  280.     errCode = noErr;
  281.     
  282.     if (!hasSys7Aliases)
  283.     {
  284.         errCode = FSOpen(fName,vRefNum,fRefNum);
  285.         
  286.         if (errCode != noErr)
  287.         {
  288.             PtoCstr(fName);
  289.             sprintf(errorMessage,"MyFSOpen: FSOpen(%s) error %d",fName,errCode);
  290.             CtoPstr(fName);
  291.             goto EXITPOINT;
  292.         }
  293.     }
  294.     
  295.     else
  296.     {
  297.         if ((errCode = FSMakeFSSpec(vRefNum,0,fName,&theSpec)) != noErr)
  298.         {
  299.             PtoCstr(fName);
  300.             sprintf(errorMessage,"MyFSOpen: FSMakeFSSpec(%s) error %d",fName,errCode);
  301.             CtoPstr(fName);
  302.             goto EXITPOINT;
  303.         }
  304.         
  305.         if ((errCode = ResolveAliasFile(&theSpec,TRUE,(Boolean *) &targetIsFolder,(Boolean *) &wasAliased)) != noErr)
  306.         {
  307.             PtoCstr(fName);
  308.             sprintf(errorMessage,"MyFSOpen: ResolveAliasFile(%s) error %d",fName,errCode);
  309.             CtoPstr(fName);
  310.             goto EXITPOINT;
  311.         }
  312.         
  313.         if (targetIsFolder)
  314.         {
  315.             PtoCstr(fName);
  316.             sprintf(errorMessage,"MyFSOpen: ResolveAliasFile(%s) resolves to a *folder*, not a file!",fName);
  317.             CtoPstr(fName);
  318.             goto EXITPOINT;
  319.         }
  320.         
  321.         if ((errCode = FSpOpenDF(&theSpec,0,fRefNum)) != noErr)
  322.         {
  323.             PtoCstr(fName);
  324.             sprintf(errorMessage,"MyFSOpen: FSpOpenDF(%s) error %d",fName,errCode);
  325.             CtoPstr(fName);
  326.             goto EXITPOINT;
  327.         }
  328.     }
  329.     
  330. EXITPOINT:
  331.  
  332.     return(errCode);
  333. }
  334.  
  335.  
  336.  
  337.  
  338.  
  339. int LoadSTRResource(char *STRName,char *theString)
  340. {
  341. Handle        resHandle;
  342. char        resName[256],tempString[256];
  343. int            errCode;
  344.  
  345.     errCode = noErr;
  346.  
  347.     mystrncpy(resName,STRName,255);
  348.     CtoPstr(resName);
  349.     
  350.     UseResFile(settingsFRefNum);
  351.     
  352.     resHandle = GetNamedResource('STR ',resName);
  353.     
  354.     errCode = ResError();
  355.     
  356.     if (resHandle==0L || errCode != noErr)
  357.     {
  358.         if (errCode == noErr)
  359.             errCode = RESERROR;
  360.         
  361.         sprintf(errorMessage,"LoadSTRResource: GetNamedResource('%s') error %d, can't get resource from 'rnMac SETTINGS' file",STRName,errCode);
  362.         
  363.         goto EXITPOINT;
  364.     }
  365.     
  366.     HLock(resHandle);
  367.     PtoCstr((char *) *resHandle);
  368.     mystrncpy(theString,(char *) *resHandle,255);
  369.     CtoPstr((char *) *resHandle);
  370.     HUnlock(resHandle);
  371.     ReleaseResource(resHandle);
  372.  
  373. EXITPOINT:
  374.     
  375.     UseResFile(rnFRefNum);
  376.     
  377.     return(errCode);
  378. }
  379.  
  380.  
  381.  
  382.  
  383. char STRResourceIsPresent(char *STRName)
  384. {
  385. Handle        resHandle;
  386. char        resName[256];
  387. int            errCode;
  388.  
  389.     errCode = noErr;
  390.     
  391.     mystrncpy(resName,STRName,255);
  392.     CtoPstr(resName);
  393.     
  394.     UseResFile(settingsFRefNum);
  395.     
  396.     resHandle = GetNamedResource('STR ',resName);
  397.     
  398.     if (resHandle == 0L || ResError() != noErr)
  399.     {
  400.         UseResFile(rnFRefNum);
  401.         return(FALSE);
  402.     }
  403.     
  404.     else
  405.     {
  406.         ReleaseResource(resHandle);
  407.         UseResFile(rnFRefNum);
  408.         return(TRUE);
  409.     }
  410. }
  411.  
  412.  
  413.  
  414.  
  415. int PutSTR(char *nameOfSTR,char *theSTR)
  416. {
  417. Handle        theSTRHandle;
  418. int            errCode;
  419. char        tempString[256];
  420.  
  421.     errCode = noErr;
  422.     theSTRHandle = 0L;
  423.     
  424.     UseResFile(settingsFRefNum);
  425.     
  426.     mystrncpy(tempString,nameOfSTR,255);
  427.     CtoPstr(tempString);
  428.     
  429.     theSTRHandle = GetNamedResource('STR ',tempString);
  430.     
  431.     if (!theSTRHandle)
  432.     {
  433.         theSTRHandle = NewHandle(256L);
  434.         
  435.         errCode = MemError();
  436.         
  437.         if (errCode != noErr || theSTRHandle == 0L)
  438.         {
  439.             if (errCode == noErr)
  440.                 errCode = memFullErr;
  441.             
  442.             sprintf(errorMessage,"PutSTR: NewHandle(256L) error %d",errCode);
  443.             
  444.             goto EXITPOINT;
  445.         }
  446.         
  447.         AddResource(theSTRHandle,'STR ',UniqueID('STR '),tempString);
  448.         
  449.         errCode = ResError();
  450.         
  451.         if (errCode != noErr)
  452.         {
  453.             DisposeHandle(theSTRHandle);
  454.             theSTRHandle = 0L;
  455.             
  456.             sprintf(errorMessage,"PutSTR: AddResource(%s) error %d",nameOfSTR,errCode);
  457.             
  458.             goto EXITPOINT;
  459.         }
  460.     }
  461.     
  462.     
  463.     SetHandleSize(theSTRHandle,(long) strlen(theSTR) + 1L);
  464.     
  465.     errCode = MemError();
  466.     
  467.     if (errCode != noErr || GetHandleSize(theSTRHandle) < strlen(theSTR) + 1L)
  468.     {
  469.         if (errCode == noErr)
  470.             errCode = memFullErr;
  471.         
  472.         sprintf(errorMessage,"PutSTR: SetHandleSize(%ld) error %d",(long) (strlen(theSTR) + 1L),errCode);
  473.         
  474.         goto EXITPOINT;
  475.     }
  476.     
  477.     HLock(theSTRHandle);
  478.     mystrncpy((char *) *theSTRHandle,theSTR,255);
  479.     CtoPstr((char *) *theSTRHandle);
  480.     HUnlock(theSTRHandle);
  481.     
  482.     ChangedResource(theSTRHandle);
  483.     WriteResource(theSTRHandle);
  484.     
  485.     
  486. EXITPOINT:
  487.  
  488.     if (theSTRHandle)
  489.         ReleaseResource(theSTRHandle);
  490.     
  491.     UseResFile(rnFRefNum);
  492.     
  493.     return(errCode);
  494. }
  495.  
  496.  
  497.  
  498.  
  499. int GetAndIncrementSEQF(char *theSeqStr)
  500. {
  501. char    seqf[256];
  502. int        fileRefNum,i,seqnum,errCode;
  503. long    byteCount;
  504. char    tempString[256];
  505.  
  506.     errCode = noErr;
  507.     fileRefNum = 0;
  508.     
  509.     if ((errCode = LoadSTRResource(CONFDIR,seqf)) != noErr)
  510.         goto EXITPOINT;
  511.     
  512.     if (strlen(seqf) <= 0 || seqf[strlen(seqf)-1] != ':')
  513.         mystrncat(seqf,":",255);
  514.     
  515.     if ((errCode = LoadSTRResource(SEQF,tempString)) != noErr)
  516.         goto EXITPOINT;
  517.     
  518.     mystrncat(seqf,tempString,255);
  519.     
  520.     CtoPstr(seqf);
  521.     
  522.     if ((errCode = MyFSOpen(seqf,vRefNum,&fileRefNum)) != noErr)
  523.         goto EXITPOINT;
  524.     
  525.     if ((errCode = SetFPos(fileRefNum,fsFromStart,0L)) != noErr)
  526.     {
  527.         PtoCstr(seqf);
  528.         sprintf(errorMessage,"GetAndIncrementSEQF: SetFPos('%s',fsFromStart) error %d",seqf,errCode);
  529.         goto EXITPOINT;
  530.     }
  531.     
  532.     if ((errCode = GetEOF(fileRefNum,&byteCount)) != noErr)
  533.     {
  534.         PtoCstr(seqf);
  535.         sprintf(errorMessage,"GetAndIncrementSEQF: GetEOF('%s') error %d",seqf,errCode);
  536.         goto EXITPOINT;
  537.     }
  538.     
  539.     if (byteCount > 10)
  540.         byteCount = 10;
  541.     
  542.     if ((errCode = FSRead(fileRefNum,&byteCount,tempString)) != noErr)
  543.     {
  544.         PtoCstr(seqf);
  545.         sprintf(errorMessage,"GetAndIncrementSEQF: FSRead('%s') error %d",seqf,errCode);
  546.         goto EXITPOINT;
  547.     }
  548.     
  549.     i = 0;
  550.     
  551.     while (tempString[i] >= '0' && tempString[i] <= '9' && i < 255)
  552.         i++;
  553.         
  554.     tempString[i] = 0;
  555.     
  556.     if (i == 0)
  557.         mystrncpy(tempString,"1",255);
  558.     
  559.     seqnum = 1;
  560.     sscanf(tempString,"%d",&seqnum);
  561.     sprintf(tempString,"%d\r",(seqnum<32767) ? seqnum+1 : 1);
  562.     
  563.     byteCount = strlen(tempString);
  564.     
  565.     if ((errCode = SetFPos(fileRefNum,fsFromStart,0L)) != noErr)
  566.     {
  567.         PtoCstr(seqf);
  568.         sprintf(errorMessage,"GetAndIncrementSEQF: SetFPos('%s',fsFromStart) error %d",seqf,errCode);
  569.         goto EXITPOINT;
  570.     }
  571.     
  572.     if ((errCode = SetEOF(fileRefNum,0L)) != noErr)
  573.     {
  574.         PtoCstr(seqf);
  575.         sprintf(errorMessage,"GetAndIncrementSEQF: SetEOF('%s') error %d",seqf,errCode);
  576.         goto EXITPOINT;
  577.     }
  578.     
  579.     if ((errCode = FSWrite(fileRefNum,&byteCount,tempString)) != noErr)
  580.     {
  581.         PtoCstr(seqf);
  582.         sprintf(errorMessage,"GetAndIncrementSEQF: FSWrite('%s',%ld) error %d",seqf,byteCount,errCode);
  583.         goto EXITPOINT;
  584.     }
  585.     
  586.     
  587.     if (seqnum < 10)
  588.         sprintf(theSeqStr,"0000%d",seqnum);
  589.     else if (seqnum < 100)
  590.         sprintf(theSeqStr,"000%d",seqnum);
  591.     else if (seqnum < 1000)
  592.         sprintf(theSeqStr,"00%d",seqnum);
  593.     else if (seqnum < 1000)
  594.         sprintf(theSeqStr,"0%d",seqnum);
  595.     else
  596.         sprintf(theSeqStr,"%d",seqnum);
  597.  
  598.  
  599. EXITPOINT:
  600.  
  601.     if (fileRefNum)
  602.     {
  603.         if (errCode == noErr)
  604.         {
  605.             if ((errCode = FSClose(fileRefNum)) != noErr)
  606.             {
  607.                 PtoCstr(seqf);
  608.                 sprintf(errorMessage,"GetAndIncrementSEQF: FSClose(%s) error %d",seqf,errCode);
  609.             }
  610.         }
  611.         
  612.         else
  613.             FSClose(fileRefNum);
  614.     }
  615.     
  616.     FlushVol("\p",vRefNum);
  617.     
  618.     return(errCode);
  619. }
  620.  
  621.  
  622.  
  623.  
  624.  
  625. int OpenAndZeroOrCreate(char *theFileName,int *theFileRefNum,int theVRefNum)
  626. {
  627. int        errCode;
  628. char    localFileName[256];
  629. char    tempString[256];
  630.  
  631.     errCode = 0;
  632.     *theFileRefNum = 0;
  633.     
  634.     mystrncpy(localFileName,theFileName,255);
  635.     CtoPstr(localFileName);
  636.     
  637.     errCode = MyFSOpen(localFileName,theVRefNum,theFileRefNum);
  638.     
  639.     if (errCode == fnfErr)
  640.     {
  641.         if ((errCode = Create(localFileName,theVRefNum,CREATOR,'TEXT')) != noErr)
  642.         {
  643.             sprintf(errorMessage,"OpenAndZeroOrCreate: Create('%s') error %d",theFileName,errCode);
  644.             goto EXITPOINT;
  645.         }
  646.         
  647.         errCode = MyFSOpen(localFileName,theVRefNum,theFileRefNum);
  648.     }
  649.     
  650.     if (errCode != noErr)
  651.     {
  652.         sprintf(errorMessage,"OpenAndZeroOrCreate: MyFSOpen('%s') error %d",theFileName,errCode);
  653.         goto EXITPOINT;
  654.     }
  655.     
  656.     if ((errCode = SetFPos(*theFileRefNum,fsFromStart,0L)) != noErr)
  657.     {
  658.         sprintf(errorMessage,"OpenAndZeroOrCreate: SetFPos('%s',fsFromStart) error %d",theFileName,errCode);
  659.         goto EXITPOINT;
  660.     }
  661.     
  662.     if ((errCode = SetEOF(*theFileRefNum,0L)) != noErr)
  663.     {
  664.         sprintf(errorMessage,"OpenAndZeroOrCreate: SetEOF('%s') error %d",theFileName,errCode);
  665.         goto EXITPOINT;
  666.     }
  667.  
  668. EXITPOINT:
  669.  
  670.     if (errCode != noErr && *theFileRefNum)
  671.     {
  672.         FSClose(*theFileRefNum);
  673.     }
  674.     
  675.     return(errCode);
  676. }
  677.  
  678.  
  679.  
  680.  
  681. int AppendTextFileAsSys67SF(Handle theTEH,sys67SFReply *thesys67SFReply)
  682. {
  683. SFTypeList            mySFTypes;
  684. Point                theTopLeft;
  685. int                    errCode,fRefNum,theVRefNum;
  686. long                byteCount;
  687. char                filename[256];
  688.  
  689.     errCode = noErr;
  690.     fRefNum = 0;
  691.     
  692.     if (hasSys7SFGetPut)
  693.     {
  694.         if (!(thesys67SFReply->sys7SFReply.sfGood))
  695.         {
  696.             mySFTypes[0] = 'TEXT';
  697.             
  698.             theTopLeft.h = -1;
  699.             theTopLeft.v = -1;
  700.         
  701.             CustomGetFile(0L,1,&mySFTypes,thesys67SFReply,customGetDLOG,theTopLeft,0L,0L,0L,0L,0L);
  702.         }
  703.         
  704.         PtoCstr((char *) thesys67SFReply->sys7SFReply.sfFile.name);
  705.         mystrncpy(filename,(char *) thesys67SFReply->sys7SFReply.sfFile.name,255);
  706.         CtoPstr((char *) thesys67SFReply->sys7SFReply.sfFile.name);
  707.         
  708.         theVRefNum = thesys67SFReply->sys7SFReply.sfFile.vRefNum;
  709.         
  710.         if (!(thesys67SFReply->sys7SFReply.sfGood))
  711.         {
  712.             errCode = USERCANCEL;
  713.             goto EXITPOINT;
  714.         }
  715.         
  716.         else if ((errCode = FSpOpenDF(&(thesys67SFReply->sys7SFReply.sfFile),0,&fRefNum)) != noErr)
  717.         {
  718.             sprintf(errorMessage,"AppendTextFileAsSys67SF: FSpOpenDF('%s') error %d",filename,errCode);
  719.             goto EXITPOINT;
  720.         }
  721.     }
  722.     
  723.     else
  724.     {
  725.         if (!(thesys67SFReply->sys6SFReply.good))
  726.         {
  727.             theTopLeft.h = screenBits.bounds.left + (screenBits.bounds.right - screenBits.bounds.left - 348)/2;;
  728.             theTopLeft.v = screenBits.bounds.top + 50;
  729.             
  730.             mySFTypes[0] = 'TEXT';
  731.             
  732.             SFGetFile(theTopLeft,"\pSelect Text File To Append To:",0L,1,&mySFTypes,0L,thesys67SFReply);
  733.         }
  734.         
  735.         PtoCstr((char *) (char *) thesys67SFReply->sys6SFReply.fName);
  736.         mystrncpy(filename,(char *) thesys67SFReply->sys6SFReply.fName,255);
  737.         CtoPstr((char *) (char *) thesys67SFReply->sys6SFReply.fName);
  738.         
  739.         theVRefNum = thesys67SFReply->sys6SFReply.vRefNum;
  740.         
  741.         if (!(thesys67SFReply->sys6SFReply.good))
  742.         {
  743.             errCode = USERCANCEL;
  744.             goto EXITPOINT;
  745.         }
  746.         
  747.         else if ((errCode = MyFSOpen((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,&fRefNum)) != noErr)
  748.             goto EXITPOINT;
  749.     }
  750.     
  751.     
  752.     if ((errCode = SetFPos(fRefNum,fsFromLEOF,0L)) != noErr)
  753.     {
  754.         sprintf(errorMessage,"AppendTextFileAsSys67SF: SetFPos('%s',0) error %d",filename,errCode);
  755.         goto EXITPOINT;
  756.     }
  757.     
  758.     byteCount = strlen(separatorString);
  759.     
  760.     if ((errCode = FSWrite(fRefNum,&byteCount,separatorString)) != noErr)
  761.     {
  762.         sprintf(errorMessage,"AppendTextFileAsSys67SF: FSWrite('%s') error %d",filename,errCode);
  763.         goto EXITPOINT;
  764.     }
  765.  
  766.     
  767.     if (useTextEdit)
  768.     {
  769.         byteCount = (**((TEHandle) theTEH)).teLength;
  770.         
  771.         HLock((**((TEHandle) theTEH)).hText);
  772.         
  773.         if ((errCode = FSWrite(fRefNum,&byteCount,*((**((TEHandle) theTEH)).hText))) != noErr)
  774.         {
  775.             sprintf(errorMessage,"AppendTextFileAsSys67SF: FSWrite('%s') error %d",filename,errCode);
  776.             goto EXITPOINT;
  777.         }
  778.     }
  779.     
  780.     else
  781.     {
  782.         byteCount = (**((TE32KHandle) theTEH)).teLength;
  783.         
  784.         HLock((**((TE32KHandle) theTEH)).hText);
  785.         
  786.         if ((errCode = FSWrite(fRefNum,&byteCount,*((**((TE32KHandle) theTEH)).hText))) != noErr)
  787.         {
  788.             sprintf(errorMessage,"AppendTextFileAsSys67SF: FSWrite('%s') error %d",filename,errCode);
  789.             goto EXITPOINT;
  790.         }
  791.     }
  792.     
  793.     
  794.  
  795. EXITPOINT:
  796.     
  797.     if (useTextEdit)
  798.         HUnlock((**((TEHandle) theTEH)).hText);
  799.     else
  800.         HUnlock((**((TE32KHandle) theTEH)).hText);
  801.     
  802.     if (fRefNum)
  803.     {
  804.         if (errCode == noErr)
  805.         {
  806.             if ((errCode = FSClose(fRefNum)) != noErr)
  807.             {
  808.                 sprintf(errorMessage,"AppendTextFileAsSys67SF: FSClose('%s',0) error %d",filename,errCode);
  809.             }
  810.         }
  811.         
  812.         else
  813.             FSClose(fRefNum);
  814.     }
  815.     
  816.     FlushVol("\p",theVRefNum);
  817.     
  818.     return(errCode);
  819. }
  820.  
  821.  
  822.  
  823.  
  824.  
  825. int AppendTextFile(Handle theTEH)
  826. {
  827. SFReply                mySFReply;
  828. SFTypeList            mySFTypes;
  829. StandardFileReply    my7SFReply;
  830. Point                theTopLeft;
  831. int                    errCode,fRefNum,theVRefNum;
  832. long                byteCount;
  833. char                fileName[256];
  834.  
  835.     errCode = noErr;
  836.     fRefNum = 0;
  837.     
  838.     if (hasSys7SFGetPut)
  839.     {
  840.         mySFTypes[0] = 'TEXT';
  841.         
  842.         theTopLeft.h = -1;
  843.         theTopLeft.v = -1;
  844.         
  845.         CustomGetFile(0L,1,&mySFTypes,&my7SFReply,customGetDLOG,theTopLeft,0L,0L,0L,0L,0L);
  846.         
  847.         PtoCstr((char *) my7SFReply.sfFile.name);
  848.         mystrncpy(fileName,(char *) my7SFReply.sfFile.name,255);
  849.         CtoPstr((char *) my7SFReply.sfFile.name);
  850.         
  851.         theVRefNum = my7SFReply.sfFile.vRefNum;
  852.         
  853.         if (!my7SFReply.sfGood)
  854.         {
  855.             errCode = USERCANCEL;
  856.             goto EXITPOINT;
  857.         }
  858.         
  859.         else if ((errCode = FSpOpenDF(&(my7SFReply.sfFile),0,&fRefNum)) != noErr)
  860.         {
  861.             sprintf(errorMessage,"AppendTextFile: FSpOpenDF('%s') error %d",fileName,errCode);
  862.             goto EXITPOINT;
  863.         }
  864.     }
  865.     
  866.     else
  867.     {
  868.         theTopLeft.h = screenBits.bounds.left + (screenBits.bounds.right - screenBits.bounds.left - 348)/2;;
  869.         theTopLeft.v = screenBits.bounds.top + 50;
  870.         
  871.         mySFTypes[0] = 'TEXT';
  872.         
  873.         SFGetFile(theTopLeft,"\pSelect Text File To Append To:",0L,1,&mySFTypes,0L,&mySFReply);
  874.         
  875.         PtoCstr((char *) (char *) mySFReply.fName);
  876.         mystrncpy(fileName,(char *) mySFReply.fName,255);
  877.         CtoPstr((char *) (char *) mySFReply.fName);
  878.         
  879.         theVRefNum = mySFReply.vRefNum;
  880.         
  881.         if (!mySFReply.good)
  882.         {
  883.             errCode = USERCANCEL;
  884.             goto EXITPOINT;
  885.         }
  886.         
  887.         else if ((errCode = MyFSOpen((char *) mySFReply.fName,mySFReply.vRefNum,&fRefNum)) != noErr)
  888.             goto EXITPOINT;
  889.     }
  890.     
  891.     
  892.     if ((errCode = SetFPos(fRefNum,fsFromLEOF,0L)) != noErr)
  893.     {
  894.         sprintf(errorMessage,"AppendTextFile: SetFPos('%s',0) error %d",fileName,errCode);
  895.         goto EXITPOINT;
  896.     }
  897.     
  898.     byteCount = strlen(separatorString);
  899.     
  900.     if ((errCode = FSWrite(fRefNum,&byteCount,separatorString)) != noErr)
  901.     {
  902.         sprintf(errorMessage,"AppendTextFile: FSWrite('%s') error %d",fileName,errCode);
  903.         goto EXITPOINT;
  904.     }
  905.  
  906.     
  907.     if (useTextEdit)
  908.     {
  909.         byteCount = (**((TEHandle) theTEH)).teLength;
  910.         
  911.         HLock((**((TEHandle) theTEH)).hText);
  912.         
  913.         if ((errCode = FSWrite(fRefNum,&byteCount,*((**((TEHandle) theTEH)).hText))) != noErr)
  914.         {
  915.             sprintf(errorMessage,"AppendTextFile: FSWrite('%s') error %d",fileName,errCode);
  916.             goto EXITPOINT;
  917.         }
  918.     }
  919.     
  920.     else
  921.     {
  922.         byteCount = (**((TE32KHandle) theTEH)).teLength;
  923.         
  924.         HLock((**((TE32KHandle) theTEH)).hText);
  925.         
  926.         if ((errCode = FSWrite(fRefNum,&byteCount,*((**((TE32KHandle) theTEH)).hText))) != noErr)
  927.         {
  928.             sprintf(errorMessage,"AppendTextFile: FSWrite('%s') error %d",fileName,errCode);
  929.             goto EXITPOINT;
  930.         }
  931.     }
  932.  
  933.  
  934. EXITPOINT:
  935.  
  936.     if (useTextEdit)
  937.         HUnlock((**((TEHandle) theTEH)).hText);
  938.     else
  939.         HUnlock((**((TE32KHandle) theTEH)).hText);
  940.     
  941.     
  942.     if (fRefNum)
  943.     {
  944.         if (errCode == noErr)
  945.         {
  946.             if ((errCode = FSClose(fRefNum)) != noErr)
  947.             {
  948.                 sprintf(errorMessage,"AppendTextFile: FSClose('%s',0) error %d",fileName,errCode);
  949.             }
  950.         }
  951.         
  952.         else
  953.             FSClose(fRefNum);
  954.     }
  955.     
  956.     FlushVol("\p",theVRefNum);
  957.     
  958.     return(errCode);
  959. }
  960.  
  961.  
  962.  
  963. int AppendTextFileAs(Handle theTEH,char *filename)
  964. {
  965. int            errCode,fRefNum,choice;
  966. long        byteCount,theCreator,theType;
  967. Handle        theText;
  968. char        pFileName[256];
  969.  
  970.     errCode = noErr;
  971.     fRefNum = 0;
  972.     theText = 0L;
  973.     
  974.     GetCreatorType(&theCreator,&theType);
  975.     
  976.     if (theTEH)
  977.     {
  978.         mystrncpy(pFileName,filename,255);
  979.         
  980.         CtoPstr(pFileName);
  981.         
  982.         errCode = MyFSOpen(pFileName,vRefNum,&fRefNum);
  983.         
  984.         if (errCode == fnfErr)
  985.         {
  986.             if ((errCode = Create(pFileName,vRefNum,theCreator,theType)) != noErr)
  987.             {
  988.                 sprintf(errorMessage,"AppendTextFileAs: Create('%s') error %d",filename,errCode);
  989.                 goto EXITPOINT;
  990.             }
  991.             
  992.             errCode = MyFSOpen(pFileName,vRefNum,&fRefNum);
  993.         }
  994.             
  995.         if (errCode != noErr)
  996.             goto EXITPOINT;
  997.             
  998.         if ((errCode = SetFPos(fRefNum,fsFromLEOF,0L)) != noErr)
  999.         {
  1000.             sprintf(errorMessage,"AppendTextFileAs: SetFPos('%s',0) error %d",filename,errCode);
  1001.             goto EXITPOINT;
  1002.         }
  1003.         
  1004.         if (useTextEdit)
  1005.         {
  1006.             theText = (**((TEHandle) theTEH)).hText;
  1007.             byteCount = (**((TEHandle) theTEH)).teLength;
  1008.         }
  1009.         else
  1010.         {
  1011.             theText = (**((TE32KHandle) theTEH)).hText;
  1012.             byteCount = (**((TE32KHandle) theTEH)).teLength;
  1013.         }
  1014.         
  1015.         HLock(theText);
  1016.         
  1017.         if ((errCode = FSWrite(fRefNum,&byteCount,*theText)) != noErr)
  1018.         {
  1019.             sprintf(errorMessage,"AppendTextFileAs: FSWrite('%s') error %d",filename,errCode);
  1020.             goto EXITPOINT;
  1021.         }
  1022.         
  1023.         HUnlock(theText);
  1024.         
  1025.         byteCount = strlen(separatorString);
  1026.         
  1027.         if ((errCode = FSWrite(fRefNum,&byteCount,separatorString)) != noErr)
  1028.         {
  1029.             sprintf(errorMessage,"AppendTextFileAs: FSWrite('%s') error %d",filename,errCode);
  1030.             goto EXITPOINT;
  1031.         }
  1032.     }
  1033.     
  1034. EXITPOINT:
  1035.  
  1036.     if (theText)
  1037.         HUnlock(theText);
  1038.     
  1039.     if (fRefNum)
  1040.     {
  1041.         if (errCode == noErr)
  1042.         {
  1043.             if ((errCode = FSClose(fRefNum)) != noErr)
  1044.             {
  1045.                 sprintf(errorMessage,"AppendTextFileAs: FSClose(%s) error %d",filename,errCode);
  1046.             }
  1047.         }
  1048.         
  1049.         else
  1050.             FSClose(fRefNum);
  1051.     }
  1052.     
  1053.     FlushVol("\p",vRefNum);
  1054.     
  1055.     return(errCode);
  1056. }
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062. int SaveTextFile(Handle theTEH,char *fileName)
  1063. {
  1064. SFReply                mySFReply;
  1065. StandardFileReply    my7SFReply;
  1066. Point                theTopLeft;
  1067. int                    errCode,fRefNum,theVRefNum;
  1068. long                byteCount,theType,theCreator;
  1069. Handle                theText;
  1070. char                localFilename[256];
  1071.  
  1072.     errCode = noErr;
  1073.     fRefNum = 0;
  1074.     theText = 0L;
  1075.     
  1076.     GetCreatorType(&theCreator,&theType);
  1077.     
  1078.     
  1079.     if (hasSys7SFGetPut)
  1080.     {
  1081.         mystrncpy(localFilename,fileName,255);
  1082.         CtoPstr(localFilename);
  1083.         
  1084.         StandardPutFile("\pSave Text File As:",localFilename,&my7SFReply);
  1085.         
  1086.         PtoCstr((char *) my7SFReply.sfFile.name);
  1087.         mystrncpy(localFilename,(char *) my7SFReply.sfFile.name,255);
  1088.         CtoPstr((char *) my7SFReply.sfFile.name);
  1089.         
  1090.         theVRefNum = my7SFReply.sfFile.vRefNum;
  1091.         
  1092.         if (!my7SFReply.sfGood)
  1093.         {
  1094.             errCode = USERCANCEL;
  1095.             goto EXITPOINT;
  1096.         }
  1097.         
  1098.         if ((errCode = FSpOpenDF(&(my7SFReply.sfFile),0,&fRefNum)) != noErr)
  1099.         {
  1100.             if (errCode==fnfErr)
  1101.             {
  1102.                 if ((errCode = FSpCreate(&(my7SFReply.sfFile),theCreator,theType,my7SFReply.sfScript)) != noErr)
  1103.                 {
  1104.                     sprintf(errorMessage,"SaveTextFile: FSpCreate('%s') error %d",localFilename,errCode);
  1105.                     goto EXITPOINT;
  1106.                 }
  1107.                 
  1108.                 errCode = FSpOpenDF(&(my7SFReply.sfFile),0,&fRefNum);
  1109.             }
  1110.         }
  1111.         
  1112.         if (errCode != noErr)
  1113.         {
  1114.             sprintf(errorMessage,"SaveTextFile: FSpOpenDF('%s') error %d",localFilename,errCode);
  1115.             goto EXITPOINT;
  1116.         }
  1117.     }
  1118.     
  1119.     else
  1120.     {
  1121.         theTopLeft.h = screenBits.bounds.left + (screenBits.bounds.right - screenBits.bounds.left - 348)/2;;
  1122.         theTopLeft.v = screenBits.bounds.top + 50;
  1123.         
  1124.         mystrncpy(localFilename,fileName,255);
  1125.         CtoPstr(localFilename);
  1126.         
  1127.         SFPutFile(theTopLeft,"\pSave Text File As:",localFilename,0L,&mySFReply);
  1128.         
  1129.         PtoCstr((char *) (char *) mySFReply.fName);
  1130.         mystrncpy(localFilename,(char *) mySFReply.fName,255);
  1131.         CtoPstr((char *) (char *) mySFReply.fName);
  1132.         
  1133.         theVRefNum = mySFReply.vRefNum;
  1134.         
  1135.         if (!mySFReply.good)
  1136.         {
  1137.             errCode = USERCANCEL;
  1138.             goto EXITPOINT;
  1139.         }
  1140.         
  1141.         if ((errCode = MyFSOpen((char *) mySFReply.fName,mySFReply.vRefNum,&fRefNum)) != noErr)
  1142.         {
  1143.             if (errCode == fnfErr)
  1144.             {
  1145.                 if ((errCode = Create(mySFReply.fName,mySFReply.vRefNum,theCreator,theType)) != noErr)
  1146.                 {
  1147.                     sprintf(errorMessage,"SaveTextFile: Create('%s') error %d",localFilename,errCode);
  1148.                     goto EXITPOINT;
  1149.                 }
  1150.                 
  1151.                 errCode = MyFSOpen((char *) mySFReply.fName,mySFReply.vRefNum,&fRefNum);
  1152.             }
  1153.         }
  1154.         
  1155.         if (errCode != noErr)
  1156.         {
  1157.             goto EXITPOINT;
  1158.         }
  1159.     }
  1160.     
  1161.     
  1162.     if ((errCode = SetEOF(fRefNum,0L)) != noErr)
  1163.     {
  1164.         sprintf(errorMessage,"SaveTextFile: SetEOF('%s',0) error %d",localFilename,errCode);
  1165.         goto EXITPOINT;
  1166.     }
  1167.     
  1168.     if ((errCode = SetFPos(fRefNum,fsFromStart,0L)) != noErr)
  1169.     {
  1170.         sprintf(errorMessage,"SaveTextFile: SetFPos('%s',fsFromStart,0) error %d",localFilename,errCode);
  1171.         goto EXITPOINT;
  1172.     }
  1173.     
  1174.     if (useTextEdit)
  1175.     {
  1176.         theText = (**((TEHandle) theTEH)).hText;
  1177.         byteCount = (**((TEHandle) theTEH)).teLength;
  1178.     }
  1179.     else
  1180.     {
  1181.         theText = (**((TE32KHandle) theTEH)).hText;
  1182.         byteCount = (**((TE32KHandle) theTEH)).teLength;
  1183.     }
  1184.     
  1185.     HLock(theText);
  1186.     
  1187.     if ((errCode = FSWrite(fRefNum,&byteCount,*theText)) != noErr)
  1188.     {
  1189.         sprintf(errorMessage,"SaveTextFile: FSWrite('%s') error %d",localFilename,errCode);
  1190.         goto EXITPOINT;
  1191.     }
  1192.     
  1193.  
  1194. EXITPOINT:
  1195.  
  1196.     if (theText)
  1197.         HUnlock(theText);
  1198.     
  1199.     if (fRefNum)
  1200.     {
  1201.         if (errCode == noErr)
  1202.         {
  1203.             if ((errCode = FSClose(fRefNum)) != noErr)
  1204.             {
  1205.                 sprintf(errorMessage,"SaveTextFile: FSClose(%s) error %d",localFilename,errCode);
  1206.             }
  1207.         }
  1208.         
  1209.         else
  1210.             FSClose(fRefNum);
  1211.     }
  1212.     
  1213.     FlushVol("\p",theVRefNum);
  1214.     
  1215.     return(errCode);
  1216. }
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222. int SaveExistingTextFile(Handle theTEH,char *defaultFilename,sys67SFReply *thesys67SFReply)
  1223. {
  1224. Point        theTopLeft;
  1225. int            errCode,fRefNum,theVRefNum;
  1226. long        byteCount,theCreator,theType;
  1227. Handle        theText;
  1228. char        filename[256];
  1229.  
  1230.     errCode = noErr;
  1231.     fRefNum = 0;
  1232.     theText = 0L;
  1233.     
  1234.     GetCreatorType(&theCreator,&theType);
  1235.     
  1236.     if (hasSys7SFGetPut)
  1237.     {
  1238.         if (!(thesys67SFReply->sys7SFReply.sfGood))
  1239.         {
  1240.             mystrncpy(filename,defaultFilename,255);
  1241.             CtoPstr(filename);
  1242.             
  1243.             StandardPutFile("\pSave Text File As:",filename,thesys67SFReply);
  1244.         }
  1245.         
  1246.         if (!(thesys67SFReply->sys7SFReply.sfGood))
  1247.         {
  1248.             errCode = USERCANCEL;
  1249.             goto EXITPOINT;
  1250.         }
  1251.         
  1252.         PtoCstr((char *) thesys67SFReply->sys7SFReply.sfFile.name);
  1253.         mystrncpy(filename,(char *) thesys67SFReply->sys7SFReply.sfFile.name,255);
  1254.         CtoPstr((char *) thesys67SFReply->sys7SFReply.sfFile.name);
  1255.         
  1256.         theVRefNum = thesys67SFReply->sys7SFReply.sfFile.vRefNum;
  1257.         
  1258.         if ((errCode = FSpOpenDF(&(thesys67SFReply->sys7SFReply.sfFile),0,&fRefNum)) != noErr)
  1259.         {
  1260.             if (errCode==fnfErr)
  1261.             {
  1262.                 if ((errCode = FSpCreate(&(thesys67SFReply->sys7SFReply.sfFile),theCreator,theType,thesys67SFReply->sys7SFReply.sfScript)) != noErr)
  1263.                 {
  1264.                     sprintf(errorMessage,"SaveExistingTextFile: FSpCreate('%s') error %d",filename,errCode);
  1265.                     goto EXITPOINT;
  1266.                 }
  1267.                 
  1268.                 errCode = FSpOpenDF(&(thesys67SFReply->sys7SFReply.sfFile),0,&fRefNum);
  1269.             }
  1270.         }
  1271.         
  1272.         if (errCode != noErr)
  1273.         {
  1274.             goto EXITPOINT;
  1275.         }
  1276.     }
  1277.     
  1278.     else
  1279.     {
  1280.         if (!(thesys67SFReply->sys6SFReply.good))
  1281.         {
  1282.             theTopLeft.h = screenBits.bounds.left + (screenBits.bounds.right - screenBits.bounds.left - 348)/2;;
  1283.             theTopLeft.v = screenBits.bounds.top + 50;
  1284.             
  1285.             mystrncpy(filename,defaultFilename,255);
  1286.             CtoPstr(filename);
  1287.             
  1288.             SFPutFile(theTopLeft,"\pSave Text File As:",filename,0L,thesys67SFReply);
  1289.         }
  1290.         
  1291.         if (!(thesys67SFReply->sys6SFReply.good))
  1292.         {
  1293.             errCode = USERCANCEL;
  1294.             goto EXITPOINT;
  1295.         }
  1296.         
  1297.         PtoCstr((char *) (char *) thesys67SFReply->sys6SFReply.fName);
  1298.         mystrncpy(filename,(char *) thesys67SFReply->sys6SFReply.fName,255);
  1299.         CtoPstr((char *) (char *) thesys67SFReply->sys6SFReply.fName);
  1300.         
  1301.         theVRefNum = thesys67SFReply->sys6SFReply.vRefNum;
  1302.         
  1303.         if ((errCode = MyFSOpen((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,&fRefNum)) != noErr)
  1304.         {
  1305.             if (errCode == fnfErr)
  1306.             {
  1307.                 if ((errCode = Create(thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,theCreator,theType)) != noErr)
  1308.                 {
  1309.                     sprintf(errorMessage,"SaveExistingTextFile: Create('%s') error %d",filename,errCode);
  1310.                     goto EXITPOINT;
  1311.                 }
  1312.                 
  1313.                 errCode = MyFSOpen((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,&fRefNum);
  1314.             }
  1315.         }
  1316.         
  1317.         if (errCode != noErr)
  1318.         {
  1319.             goto EXITPOINT;
  1320.         }
  1321.     }
  1322.     
  1323.     if ((errCode = SetEOF(fRefNum,0L)) != noErr)
  1324.     {
  1325.         sprintf(errorMessage,"SaveExistingTextFile: SetEOF('%s',0) error %d",filename,errCode);
  1326.         goto EXITPOINT;
  1327.     }
  1328.     
  1329.     if ((errCode = SetFPos(fRefNum,fsFromStart,0L)) != noErr)
  1330.     {
  1331.         sprintf(errorMessage,"SaveExistingTextFile: SetFPos('%s',fsFromStart,0) error %d",filename,errCode);
  1332.         goto EXITPOINT;
  1333.     }
  1334.     
  1335.     if (useTextEdit)
  1336.     {
  1337.         theText = (**((TEHandle) theTEH)).hText;
  1338.         byteCount = (**((TEHandle) theTEH)).teLength;
  1339.     }
  1340.     
  1341.     else
  1342.     {
  1343.         theText = (**((TE32KHandle) theTEH)).hText;
  1344.         byteCount = (**((TE32KHandle) theTEH)).teLength;
  1345.     }
  1346.     
  1347.     HLock(theText);
  1348.     
  1349.     if ((errCode = FSWrite(fRefNum,&byteCount,*theText)) != noErr)
  1350.     {
  1351.         sprintf(errorMessage,"SaveExistingTextFile: FSWrite('%s') error %d",filename,errCode);
  1352.         goto EXITPOINT;
  1353.     }
  1354.     
  1355.     
  1356. EXITPOINT:
  1357.  
  1358.     if (theText)
  1359.         HUnlock(theText);
  1360.     
  1361.     if (fRefNum)
  1362.     {
  1363.         if (errCode == noErr)
  1364.         {
  1365.             if ((errCode = FSClose(fRefNum)) != noErr)
  1366.             {
  1367.                 sprintf(errorMessage,"SaveExistingTextFile: FSClose(%s) error %d",filename,errCode);
  1368.             }
  1369.         }
  1370.         
  1371.         else
  1372.             FSClose(fRefNum);
  1373.     }
  1374.     
  1375.     
  1376.     FlushVol("\p",theVRefNum);
  1377.     
  1378.     return(errCode);
  1379. }
  1380.  
  1381.  
  1382.  
  1383.  
  1384. int InsertTextFile(Handle theTEH)
  1385. {
  1386. SFReply                mySFReply;
  1387. StandardFileReply    my7SFReply;
  1388. SFTypeList            mySFTypes;
  1389. Point                theTopLeft;
  1390. int                    errCode,fRefNum,theVRefNum;
  1391. long                byteCount;
  1392. Ptr                    theText;
  1393. char                filename[256];
  1394.  
  1395.     errCode = noErr;
  1396.     theText = 0L;
  1397.     fRefNum = 0;
  1398.     
  1399.     if (hasSys7SFGetPut)
  1400.     {
  1401.         mySFTypes[0] = 'TEXT';
  1402.         
  1403.         StandardGetFile(0L,1,&mySFTypes,&my7SFReply);
  1404.         
  1405.         PtoCstr((char *) my7SFReply.sfFile.name);
  1406.         mystrncpy(filename,(char *) my7SFReply.sfFile.name,255);
  1407.         CtoPstr((char *) my7SFReply.sfFile.name);
  1408.         
  1409.         theVRefNum = my7SFReply.sfFile.vRefNum;
  1410.         
  1411.         if (my7SFReply.sfGood)
  1412.         {
  1413.             if ((errCode = FSpOpenDF(&(my7SFReply.sfFile),0,&fRefNum)) != noErr)
  1414.             {
  1415.                 sprintf(errorMessage,"InsertTextFile: FSpOpenDF('%s') error %d",filename,errCode);
  1416.                 goto EXITPOINT;
  1417.             }
  1418.         }
  1419.         
  1420.         else
  1421.         {
  1422.             errCode = USERCANCEL;
  1423.             goto EXITPOINT;
  1424.         }
  1425.     }
  1426.     
  1427.     else
  1428.     {
  1429.         theTopLeft.h = screenBits.bounds.left + (screenBits.bounds.right - screenBits.bounds.left - 348)/2;;
  1430.         theTopLeft.v = screenBits.bounds.top + 50;
  1431.         
  1432.         mySFTypes[0] = 'TEXT';
  1433.         
  1434.         SFGetFile(theTopLeft,"\pSelect Text File To Insert:",0L,1,&mySFTypes,0L,&mySFReply);
  1435.         
  1436.         PtoCstr((char *) (char *) mySFReply.fName);
  1437.         mystrncpy(filename,(char *) mySFReply.fName,255);
  1438.         CtoPstr((char *) (char *) mySFReply.fName);
  1439.         
  1440.         theVRefNum = mySFReply.vRefNum;
  1441.         
  1442.         if (mySFReply.good)
  1443.         {
  1444.             if ((errCode = MyFSOpen((char *) mySFReply.fName,mySFReply.vRefNum,&fRefNum)) != noErr)
  1445.                 goto EXITPOINT;
  1446.         }
  1447.         
  1448.         else
  1449.         {
  1450.             errCode = USERCANCEL;
  1451.             goto EXITPOINT;
  1452.         }
  1453.     }
  1454.         
  1455.     if ((errCode = GetEOF(fRefNum,&byteCount)) != noErr)
  1456.     {
  1457.         sprintf(errorMessage,"InsertTextFile: GetEOF('%s') error %d",filename,errCode);
  1458.         goto EXITPOINT;
  1459.     }
  1460.     
  1461.     if ((errCode = SetFPos(fRefNum,fsFromStart,0L)) != noErr)
  1462.     {
  1463.         sprintf(errorMessage,"InsertTextFile: SetFPos('%s',fsFromStart,0) error %d",filename,errCode);
  1464.         goto EXITPOINT;
  1465.     }
  1466.     
  1467.     theText = NewPtr(byteCount);
  1468.     
  1469.     errCode = MemError();
  1470.     
  1471.     if (theText == 0L || errCode != noErr)
  1472.     {
  1473.         if (errCode == noErr)
  1474.             errCode = memFullErr;
  1475.         
  1476.         sprintf(errorMessage,"InsertTextFile: NewPtr(%ld) error %d",byteCount,errCode);
  1477.         goto EXITPOINT;
  1478.     }
  1479.     
  1480.     if ((errCode = FSRead(fRefNum,&byteCount,theText)) != noErr)
  1481.     {
  1482.         sprintf(errorMessage,"InsertTextFile: FSRead('%s') error %d",filename,errCode);
  1483.         goto EXITPOINT;
  1484.     }
  1485.     
  1486.     if (useTextEdit)
  1487.         TEInsert(theText,byteCount,(TEHandle) theTEH);
  1488.     
  1489.     else
  1490.         TE32KInsert(theText,byteCount,(TE32KHandle) theTEH);
  1491.     
  1492.     
  1493. EXITPOINT:
  1494.  
  1495.     if (theText)
  1496.         DisposePtr(theText);
  1497.     
  1498.     if (fRefNum)
  1499.     {
  1500.         if (errCode == noErr)
  1501.         {
  1502.             if ((errCode = FSClose(fRefNum)) != noErr)
  1503.             {
  1504.                 sprintf(errorMessage,"InsertTextFile: FSClose(%s) error %d",filename,errCode);
  1505.             }
  1506.         }
  1507.         
  1508.         else
  1509.             FSClose(fRefNum);
  1510.     }
  1511.     
  1512.     
  1513.     return(errCode);
  1514. }
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520. int InsertNamedTextFile(char *filename,Handle theTEH)
  1521. {
  1522. int            errCode,fRefNum;
  1523. long        byteCount;
  1524. Ptr            theText;
  1525. char        tempString[256],pFileName[256];
  1526.  
  1527.     errCode = noErr;
  1528.     fRefNum = 0;
  1529.     theText = 0L;
  1530.     
  1531.     if (theTEH)
  1532.     {
  1533.         mystrncpy(pFileName,filename,255);
  1534.         CtoPstr(pFileName);
  1535.         
  1536.         if ((errCode = MyFSOpen(pFileName,vRefNum,&fRefNum)) != noErr)
  1537.             goto EXITPOINT;
  1538.             
  1539.         
  1540.         if ((errCode = GetEOF(fRefNum,&byteCount)) != noErr)
  1541.         {
  1542.             sprintf(errorMessage,"InsertNamedTextFile: GetEOF('%s',0) error %d",filename,errCode);
  1543.             goto EXITPOINT;
  1544.         }
  1545.         
  1546.         if ((errCode = SetFPos(fRefNum,fsFromStart,0L)) != noErr)
  1547.         {
  1548.             sprintf(errorMessage,"InsertNamedTextFile: SetFPos('%s',0) error %d",filename,errCode);
  1549.             goto EXITPOINT;
  1550.         }
  1551.         
  1552.         theText = NewPtr(byteCount);
  1553.         
  1554.         errCode = MemError();
  1555.         
  1556.         if (errCode != noErr || theText==0L)
  1557.         {
  1558.             if (errCode == noErr)
  1559.                 errCode = memFullErr;
  1560.             
  1561.             sprintf(errorMessage,"InsertNamedTextFile: NewPtr(%ld) error %d",byteCount,errCode);
  1562.             goto EXITPOINT;
  1563.         }
  1564.         
  1565.         if ((errCode = FSRead(fRefNum,&byteCount,theText)) != noErr)
  1566.         {
  1567.             sprintf(errorMessage,"InsertNamedTextFile: FSRead('%s') error %d",filename,errCode);
  1568.             goto EXITPOINT;
  1569.         }
  1570.         
  1571.         if (useTextEdit)
  1572.             TEInsert(theText,byteCount,(TEHandle) theTEH);
  1573.         else
  1574.             TE32KInsert(theText,byteCount,(TE32KHandle) theTEH);
  1575.     }
  1576.         
  1577. EXITPOINT:
  1578.     
  1579.     if (theText)
  1580.         DisposPtr(theText);
  1581.     
  1582.     if (fRefNum)
  1583.     {
  1584.         if (errCode == noErr)
  1585.         {
  1586.             if ((errCode = FSClose(fRefNum)) != noErr)
  1587.             {
  1588.                 sprintf(errorMessage,"InsertNamedTextFile: FSClose(%s) error %d",filename,errCode);
  1589.             }
  1590.         }
  1591.         
  1592.         else
  1593.             FSClose(fRefNum);
  1594.     }
  1595.  
  1596.     return(errCode);
  1597. }
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604. int GetWDDirID(int wdRefNum,long *dirID)
  1605. {
  1606. int            length,errCode;
  1607. WDPBRec        myWDPB;
  1608. char        tempString[256];
  1609.  
  1610.     errCode = noErr;
  1611.     *dirID = 0L;
  1612.     
  1613.     myWDPB.ioCompletion = 0L;
  1614.     myWDPB.ioNamePtr = 0L;
  1615.     myWDPB.ioVRefNum = wdRefNum;
  1616.     myWDPB.ioWDIndex = 0;
  1617.     myWDPB.ioWDProcID = 0L;
  1618.     
  1619.     if ((errCode = PBGetWDInfo(&myWDPB,FALSE)) != noErr)
  1620.     {
  1621.         sprintf(errorMessage,"GetWDDirID: PBGetWDInfo() error %d",errCode);
  1622.         goto EXITPOINT;
  1623.     }
  1624.     
  1625.     *dirID = myWDPB.ioWDDirID;
  1626.  
  1627. EXITPOINT:
  1628.  
  1629.     return(errCode);
  1630. }
  1631.  
  1632.  
  1633.  
  1634.  
  1635. int OpenWorkingDirectory(long dirID,int theVRefNum,int *wdRefNum)
  1636. {
  1637. int            length,errCode;
  1638. WDPBRec        myWDPB;
  1639.  
  1640.     errCode = noErr;
  1641.     *wdRefNum = 0;
  1642.     
  1643.     myWDPB.ioCompletion = 0L;
  1644.     myWDPB.ioNamePtr = 0L;
  1645.     myWDPB.ioVRefNum = theVRefNum;
  1646.     myWDPB.ioWDProcID = 0L;
  1647.     myWDPB.ioWDDirID = dirID;
  1648.     
  1649.     errCode = PBOpenWD(&myWDPB,FALSE);
  1650.     
  1651.     if (errCode == noErr)
  1652.     {
  1653.         *wdRefNum = myWDPB.ioVRefNum;
  1654.     }
  1655.     
  1656.     return(errCode);
  1657. }
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663. int CloseWorkingDirectory(int wdRefNum)
  1664. {
  1665. int            errCode;
  1666. WDPBRec        myWDPB;
  1667. char        tempString[256];
  1668.  
  1669.     myWDPB.ioCompletion = 0L;
  1670.     myWDPB.ioVRefNum = wdRefNum;
  1671.     
  1672.     errCode = PBCloseWD(&myWDPB,FALSE);
  1673.     
  1674.     if (errCode != noErr)
  1675.     {
  1676.         sprintf(errorMessage,"CloseWorkingDirectory: PBCloseWD error %d",errCode);
  1677.     }
  1678.     
  1679.     return(errCode);
  1680. }
  1681.  
  1682.  
  1683.  
  1684.  
  1685. int GetFileDirID(char *theFilePathAndName,int vRefNum,long *dirID)
  1686. {
  1687. int                length,errCode;
  1688. CInfoPBRec        theCPB;
  1689. char            tempString[256];
  1690.  
  1691.     errCode = noErr;
  1692.     *dirID = 0L;
  1693.     
  1694.     mystrncpy(tempString,theFilePathAndName,255);
  1695.     CtoPstr(tempString);
  1696.     
  1697.     theCPB.hFileInfo.ioCompletion = 0L;
  1698.     theCPB.hFileInfo.ioNamePtr = (StringPtr) tempString;
  1699.     theCPB.hFileInfo.ioVRefNum = vRefNum;
  1700.     theCPB.hFileInfo.ioFDirIndex = 0;
  1701.     theCPB.hFileInfo.ioDirID = 0L;
  1702.     
  1703.     errCode = PBGetCatInfo(&theCPB,FALSE);
  1704.     
  1705.     if (errCode != noErr)
  1706.     {
  1707.         sprintf(errorMessage,"GetFileDirID: PBGetCatInfo() error %d",errCode);
  1708.         goto EXITPOINT;
  1709.     }
  1710.     
  1711.     *dirID = theCPB.hFileInfo.ioFlParID;
  1712.     
  1713. EXITPOINT:
  1714.  
  1715.     return(errCode);
  1716. }
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725. static int createFolder(char *theSTRName,char *didCreate)
  1726. {
  1727. char        tempString[256],theSTR[256];
  1728. CInfoPBRec    myCPB;
  1729. int            i,errCode;
  1730.  
  1731.     errCode = noErr;
  1732.     *didCreate = FALSE;
  1733.     
  1734.     errCode = LoadSTRResource(theSTRName,theSTR);
  1735.     
  1736.     if (errCode == noErr)
  1737.     {
  1738.         i = strlen(theSTR);
  1739.         if (i > 0 && i < 255 && theSTR[i-1] != ':')
  1740.         {
  1741.             theSTR[i] = ':';
  1742.             theSTR[i+1] = 0;
  1743.         }
  1744.         
  1745.         CtoPstr(theSTR);
  1746.         
  1747.         myCPB.hFileInfo.ioCompletion = 0L;
  1748.         myCPB.hFileInfo.ioNamePtr = (StringPtr) &theSTR;
  1749.         myCPB.hFileInfo.ioVRefNum = vRefNum;
  1750.         myCPB.hFileInfo.ioFDirIndex = 0L;
  1751.         myCPB.hFileInfo.ioDirID = 0L;
  1752.         
  1753.         errCode = PBGetCatInfo(&myCPB,FALSE);
  1754.         
  1755.         if (errCode != noErr)
  1756.         {
  1757.             myCPB.hFileInfo.ioCompletion = 0L;
  1758.             myCPB.hFileInfo.ioNamePtr = (StringPtr) &theSTR;
  1759.             myCPB.hFileInfo.ioVRefNum = vRefNum;
  1760.             myCPB.hFileInfo.ioFDirIndex = 0L;
  1761.             myCPB.hFileInfo.ioDirID = 0L;
  1762.             
  1763.             errCode = PBDirCreate(&myCPB,FALSE);
  1764.             
  1765.             if (errCode != noErr)
  1766.             {
  1767.                 PtoCstr(theSTR);
  1768.                 sprintf(errorMessage,"createFolder: PBDirCreate('%s') error %d",theSTR,errCode);
  1769.                 goto EXITPOINT;
  1770.             }
  1771.             
  1772.             *didCreate = TRUE;
  1773.         }
  1774.         
  1775.         else if (!(myCPB.hFileInfo.ioFlAttrib & 0x10))
  1776.         {
  1777.             errCode = FILEWASFOLDER;
  1778.             PtoCstr(theSTR);
  1779.             PtoCstr(theSTRName);
  1780.             sprintf(errorMessage,"createFolder: setting %s = '%s' exists but is not a folder!",theSTRName,theSTR);
  1781.             goto EXITPOINT;
  1782.         }
  1783.     }
  1784.     
  1785. EXITPOINT:
  1786.  
  1787.     return(errCode);
  1788. }
  1789.  
  1790.  
  1791.  
  1792.  
  1793. int createNeededFolders(void)
  1794. {
  1795. char    tempString[256],seqf[256],didCreate;
  1796. int        fileRefNum,errCode,i;
  1797. long    byteCount;
  1798.  
  1799.     errCode = noErr;
  1800.     fileRefNum = 0;
  1801.     
  1802.     if ((errCode = createFolder(MAILDIR,&didCreate)) != noErr)
  1803.         goto EXITPOINT;
  1804.     
  1805.     if (STRResourceIsPresent(ARTICLEFOLDER) == TRUE)
  1806.     {
  1807.         if ((errCode = createFolder(ARTICLEFOLDER,&didCreate)) != noErr)
  1808.             goto EXITPOINT;
  1809.     }
  1810.     
  1811.     if ((errCode = createFolder(NEWSFOLDER,&didCreate)) != noErr)
  1812.         goto EXITPOINT;
  1813.     
  1814.     if ((errCode = createFolder(SPOOLDIR,&didCreate)) != noErr)
  1815.         goto EXITPOINT;
  1816.     
  1817.     
  1818.     if ((errCode = createFolder(CONFDIR,&didCreate)) != noErr)
  1819.         goto EXITPOINT;
  1820.     
  1821.     else if (didCreate)
  1822.     {
  1823.         if ((errCode = LoadSTRResource(SEQF,seqf)) != noErr)
  1824.             goto EXITPOINT;
  1825.         
  1826.         if ((errCode = LoadSTRResource(CONFDIR,tempString)) != noErr)
  1827.             goto EXITPOINT;
  1828.         
  1829.         i = strlen(tempString);
  1830.         if (i > 0 && i < 255 && tempString[i-1] != ':')
  1831.         {
  1832.             tempString[i] = ':';
  1833.             tempString[i+1] = 0;
  1834.         }
  1835.         
  1836.         mystrncat(tempString,seqf,255);
  1837.         mystrncpy(seqf,tempString,255);
  1838.                 
  1839.         if ((errCode = OpenAndZeroOrCreate(seqf,&fileRefNum,vRefNum)) != noErr)
  1840.             goto EXITPOINT;
  1841.         
  1842.         strcpy(tempString,"1");
  1843.         byteCount = strlen(tempString);
  1844.         
  1845.         if ((errCode = FSWrite(fileRefNum,&byteCount,tempString)) != noErr)
  1846.         {
  1847.             sprintf(errorMessage,"createNeededFolders: FSWrite('%s',%ld) error %d",seqf,byteCount,errCode);
  1848.             goto EXITPOINT;
  1849.         }
  1850.     }
  1851.     
  1852. EXITPOINT:
  1853.  
  1854.     if (fileRefNum)
  1855.     {
  1856.         if (errCode == noErr)
  1857.         {
  1858.             if ((errCode = FSClose(fileRefNum)) != noErr)
  1859.             {
  1860.                 sprintf(errorMessage,"createNeededFolders: FSClose(%s) error %d",seqf,errCode);
  1861.             }
  1862.         }
  1863.         
  1864.         else
  1865.             FSClose(fileRefNum);
  1866.     }
  1867.  
  1868.     return(errCode);
  1869. }
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875. void ExtractSFFileName(sys67SFReply *thesys67SFReply,char *fileName)
  1876. {
  1877.     if (hasSys7SFGetPut)
  1878.     {
  1879.         PtoCstr((char *) thesys67SFReply->sys7SFReply.sfFile.name);
  1880.         mystrncpy(fileName,(char *) thesys67SFReply->sys7SFReply.sfFile.name,63);
  1881.         CtoPstr((char *) thesys67SFReply->sys7SFReply.sfFile.name);
  1882.     }
  1883.     
  1884.     else
  1885.     {
  1886.         PtoCstr((char *) thesys67SFReply->sys6SFReply.fName);
  1887.         mystrncpy(fileName,(char *) thesys67SFReply->sys6SFReply.fName,63);
  1888.         CtoPstr((char *) thesys67SFReply->sys6SFReply.fName);
  1889.     }
  1890. }
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896. int SelectInputFile(sys67SFReply *thesys67SFReply,SFTypeList *theSFTypes,int numTypes)
  1897. {
  1898. Point        theTopLeft;
  1899. int            errCode;
  1900.     
  1901.     errCode = noErr;
  1902.     
  1903.     
  1904.     if (hasSys7SFGetPut)
  1905.     {
  1906.         StandardGetFile(0L,numTypes,theSFTypes,&(thesys67SFReply->sys7SFReply));
  1907.         
  1908.         if (!thesys67SFReply->sys7SFReply.sfGood)
  1909.             errCode = USERCANCEL;
  1910.     }
  1911.     
  1912.     
  1913.     else
  1914.     {
  1915.         theTopLeft.h = screenBits.bounds.left + (screenBits.bounds.right - screenBits.bounds.left - 348)/2;
  1916.         theTopLeft.v = screenBits.bounds.top + 50;
  1917.         
  1918.         if (theTopLeft.h < 50)
  1919.             theTopLeft.h = 50;
  1920.         
  1921.         if (theTopLeft.v < 50)
  1922.             theTopLeft.v = 50;
  1923.         
  1924.         SFGetFile(theTopLeft,"\pSelect File:",0L,numTypes,theSFTypes,0L,&(thesys67SFReply->sys6SFReply));
  1925.         
  1926.         if (!thesys67SFReply->sys6SFReply.good)
  1927.             errCode = USERCANCEL;
  1928.     }
  1929.     
  1930.     return(errCode);
  1931. }
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937. int SelectOutputFile(sys67SFReply *thesys67SFReply,char *defaultName)
  1938. {
  1939. Point        theTopLeft;
  1940. int            errCode;
  1941. char        fileName[64];
  1942.  
  1943.     errCode = noErr;
  1944.     
  1945.     mystrncpy(fileName,defaultName,63);
  1946.     CtoPstr(fileName);
  1947.     
  1948.     if (hasSys7SFGetPut)
  1949.     {
  1950.         StandardPutFile("\pSave File As:",fileName,&(thesys67SFReply->sys7SFReply));
  1951.         
  1952.         if (!thesys67SFReply->sys7SFReply.sfGood)
  1953.             errCode = -1;
  1954.     }
  1955.     
  1956.     else
  1957.     {
  1958.         theTopLeft.h = screenBits.bounds.left + (screenBits.bounds.right - screenBits.bounds.left - 304)/2;;
  1959.         theTopLeft.v = screenBits.bounds.top + 50;
  1960.         
  1961.         if (theTopLeft.h < 50)
  1962.             theTopLeft.h = 50;
  1963.         
  1964.         if (theTopLeft.v < 50)
  1965.             theTopLeft.v = 50;
  1966.         
  1967.         SFPutFile(theTopLeft,"\pSave File As:",fileName,0L,&(thesys67SFReply->sys6SFReply));
  1968.         
  1969.         if (!thesys67SFReply->sys6SFReply.good)
  1970.             errCode = -1;
  1971.     }
  1972.     
  1973.     return(errCode);
  1974. }
  1975.  
  1976.  
  1977.  
  1978.  
  1979. int GetSFTypeCreatorFlags(sys67SFReply *thesys67SFReply,long *theType,long *theCreator,unsigned int *theFlags)
  1980. {
  1981. int        errCode;
  1982. FInfo    fndrInfo;
  1983. char    fileName[64];
  1984.  
  1985.     *theType = 0L;
  1986.     *theCreator = 0L;
  1987.     *theFlags = 0;
  1988.     
  1989.     ExtractSFFileName(thesys67SFReply,fileName);
  1990.     
  1991.     if (hasSys7SFGetPut)
  1992.     {
  1993.         errCode = FSpGetFInfo(&(thesys67SFReply->sys7SFReply.sfFile),&fndrInfo);
  1994.         
  1995.         if (errCode != noErr)
  1996.             sprintf(errorMessage,"GetSFTypeCreatorFlags: FSpGetFInfo('%s') error %d",fileName,errCode);
  1997.         
  1998.         else
  1999.         {
  2000.             *theType = fndrInfo.fdType;
  2001.             *theCreator = fndrInfo.fdCreator;
  2002.             *theFlags = fndrInfo.fdFlags;
  2003.         }
  2004.     }
  2005.     
  2006.     else
  2007.     {
  2008.         errCode = GetFInfo((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,&fndrInfo);
  2009.         
  2010.         if (errCode != noErr)
  2011.             sprintf(errorMessage,"GetSFTypeCreatorFlags: GetFInfo('%s') error %d",fileName,errCode);
  2012.         
  2013.         else
  2014.         {
  2015.             *theType = fndrInfo.fdType;
  2016.             *theCreator = fndrInfo.fdCreator;
  2017.             *theFlags = fndrInfo.fdFlags;
  2018.         }
  2019.     }
  2020.     
  2021.     return(errCode);
  2022. }
  2023.  
  2024.  
  2025.  
  2026.  
  2027. int SetSFTypeCreatorFlags(sys67SFReply *thesys67SFReply,long theType,long theCreator,unsigned int theFlags)
  2028. {
  2029. int        errCode;
  2030. FInfo    fndrInfo;
  2031. char    fileName[64];
  2032.  
  2033.  
  2034.     ExtractSFFileName(thesys67SFReply,fileName);
  2035.     
  2036.     if (hasSys7SFGetPut)
  2037.     {
  2038.         errCode = FSpGetFInfo(&(thesys67SFReply->sys7SFReply.sfFile),&fndrInfo);
  2039.         
  2040.         if (errCode != noErr)
  2041.             sprintf(errorMessage,"SetSFTypeCreatorFlags: FSpGetFInfo('%s') error %d",fileName,errCode);
  2042.         
  2043.         else
  2044.         {
  2045.             fndrInfo.fdType = theType;
  2046.             fndrInfo.fdCreator = theCreator;
  2047.             fndrInfo.fdFlags = theFlags;
  2048.             
  2049.             errCode = FSpSetFInfo(&(thesys67SFReply->sys7SFReply.sfFile),&fndrInfo);
  2050.             
  2051.             if (errCode != noErr)
  2052.                 sprintf(errorMessage,"SetSFTypeCreatorFlags: FSpSetFInfo('%s') error %d",fileName,errCode);
  2053.         }
  2054.     }
  2055.     
  2056.     else
  2057.     {
  2058.         errCode = GetFInfo((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,&fndrInfo);
  2059.         
  2060.         if (errCode != noErr)
  2061.             sprintf(errorMessage,"SetSFTypeCreatorFlags: GetFInfo('%s') error %d",fileName,errCode);
  2062.         
  2063.         else
  2064.         {
  2065.             fndrInfo.fdType = theType;
  2066.             fndrInfo.fdCreator = theCreator;
  2067.             fndrInfo.fdFlags = theFlags;
  2068.             
  2069.             errCode = SetFInfo((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,&fndrInfo);
  2070.             
  2071.             if (errCode != noErr)
  2072.                 sprintf(errorMessage,"SetSFTypeCreatorFlags: SetFInfo('%s') error %d",fileName,errCode);
  2073.         }
  2074.     }
  2075.     
  2076.     return(errCode);
  2077. }
  2078.  
  2079.  
  2080.  
  2081.  
  2082. int GetDataForkLength(sys67SFReply *thesys67SFReply,long *dataForkLength)
  2083. {
  2084. int            errCode,fRefNum;
  2085. long        byteCount;
  2086. char        theFileName[64];
  2087.  
  2088.  
  2089.     errCode = noErr;
  2090.     *dataForkLength = 0L;
  2091.     
  2092.     ExtractSFFileName(thesys67SFReply,theFileName);
  2093.     
  2094.     if (hasSys7SFGetPut)
  2095.     {
  2096.         if ((errCode = FSpOpenDF(&(thesys67SFReply->sys7SFReply.sfFile),0,&fRefNum)) != noErr)
  2097.         {
  2098.             sprintf(errorMessage,"GetDataForkLength: FSpOpenDF('%s') error %d",theFileName,errCode);
  2099.             goto EXITPOINT;
  2100.         }
  2101.     }
  2102.     
  2103.     else
  2104.     {
  2105.         if ((errCode = FSOpen((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,&fRefNum)) != noErr)
  2106.         {
  2107.             sprintf(errorMessage,"GetDataForkLength: FSOpen('%s') error %d",theFileName,errCode);
  2108.             goto EXITPOINT;
  2109.         }
  2110.     }
  2111.     
  2112.     if ((errCode = GetEOF(fRefNum,&byteCount)) != noErr)
  2113.     {
  2114.         FSClose(fRefNum);
  2115.         sprintf(errorMessage,"GetDataForkLength: GetEOF('%s') error %d",theFileName,errCode);
  2116.         goto EXITPOINT;
  2117.     }
  2118.     
  2119.     if ((errCode = FSClose(fRefNum)) != noErr)
  2120.     {
  2121.         sprintf(errorMessage,"GetDataForkLength: FSClose('%s') error %d",theFileName,errCode);
  2122.         goto EXITPOINT;
  2123.     }
  2124.     
  2125.     *dataForkLength = byteCount;
  2126.     
  2127. EXITPOINT:
  2128.  
  2129.     return(errCode);
  2130. }
  2131.  
  2132.  
  2133.  
  2134.  
  2135. int GetResourceForkLength(sys67SFReply *thesys67SFReply,long *resForkLength)
  2136. {
  2137. int            errCode,fRefNum;
  2138. long        byteCount;
  2139. char        theFileName[64];
  2140.  
  2141.  
  2142.     errCode = noErr;
  2143.     *resForkLength = 0L;
  2144.     
  2145.     ExtractSFFileName(thesys67SFReply,theFileName);
  2146.     
  2147.     if (hasSys7SFGetPut)
  2148.     {
  2149.         if ((errCode = FSpOpenRF(&(thesys67SFReply->sys7SFReply.sfFile),0,&fRefNum)) != noErr)
  2150.         {
  2151.             sprintf(errorMessage,"GetResourceForkLength: FSpOpenRF('%s') error %d",theFileName,errCode);
  2152.             goto EXITPOINT;
  2153.         }
  2154.     }
  2155.     
  2156.     else
  2157.     {
  2158.         if ((errCode = OpenRF((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,&fRefNum)) != noErr)
  2159.         {
  2160.             sprintf(errorMessage,"GetResourceForkLength: OpenRF('%s') error %d",theFileName,errCode);
  2161.             goto EXITPOINT;
  2162.         }
  2163.     }
  2164.     
  2165.     if ((errCode = GetEOF(fRefNum,&byteCount)) != noErr)
  2166.     {
  2167.         FSClose(fRefNum);
  2168.         sprintf(errorMessage,"GetResourceForkLength: GetEOF('%s') error %d",theFileName,errCode);
  2169.         goto EXITPOINT;
  2170.     }
  2171.     
  2172.     if ((errCode = FSClose(fRefNum)) != noErr)
  2173.     {
  2174.         sprintf(errorMessage,"GetResourceForkLength: FSClose('%s') error %d",theFileName,errCode);
  2175.         goto EXITPOINT;
  2176.     }
  2177.     
  2178.     *resForkLength = byteCount;
  2179.     
  2180. EXITPOINT:
  2181.  
  2182.     return(errCode);
  2183. }
  2184.  
  2185.  
  2186.  
  2187.  
  2188. int OpenDataFork(sys67SFReply *thesys67SFReply,int *fRefNum)
  2189. {
  2190. int            errCode;
  2191. char        theFileName[64];
  2192.  
  2193.  
  2194.     errCode = noErr;
  2195.     
  2196.     *fRefNum = 0;
  2197.     
  2198.     ExtractSFFileName(thesys67SFReply,theFileName);
  2199.     
  2200.     if (hasSys7SFGetPut)
  2201.     {
  2202.         if ((errCode = FSpOpenDF(&(thesys67SFReply->sys7SFReply.sfFile),0,fRefNum)) != noErr)
  2203.         {
  2204.             sprintf(errorMessage,"OpenDataFork: FSpOpenDF('%s') error %d",theFileName,errCode);
  2205.             goto EXITPOINT;
  2206.         }
  2207.     }
  2208.     
  2209.     else
  2210.     {
  2211.         if ((errCode = FSOpen((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,fRefNum)) != noErr)
  2212.         {
  2213.             sprintf(errorMessage,"OpenDataFork: FSOpen('%s') error %d",theFileName,errCode);
  2214.             goto EXITPOINT;
  2215.         }
  2216.     }
  2217.     
  2218.     if ((errCode = SetFPos(*fRefNum,fsFromStart,0L)) != noErr)
  2219.     {
  2220.         FSClose(*fRefNum);
  2221.         *fRefNum = 0;
  2222.         sprintf(errorMessage,"OpenDataFork: SetFPos('%s',fsFromStart,0L) error %d",theFileName,errCode);
  2223.         goto EXITPOINT;
  2224.     }
  2225.     
  2226. EXITPOINT:
  2227.  
  2228.     return(errCode);
  2229. }
  2230.  
  2231.  
  2232.  
  2233.  
  2234. int OpenResourceFork(sys67SFReply *thesys67SFReply,int *fRefNum)
  2235. {
  2236. int            errCode;
  2237. char        theFileName[64];
  2238.  
  2239.  
  2240.     errCode = noErr;
  2241.     
  2242.     *fRefNum = 0;
  2243.     
  2244.     ExtractSFFileName(thesys67SFReply,theFileName);
  2245.     
  2246.     if (hasSys7SFGetPut)
  2247.     {
  2248.         if ((errCode = FSpOpenRF(&(thesys67SFReply->sys7SFReply.sfFile),0,fRefNum)) != noErr)
  2249.         {
  2250.             sprintf(errorMessage,"OpenResourceFork: FSpOpenRF('%s') error %d",theFileName,errCode);
  2251.             goto EXITPOINT;
  2252.         }
  2253.     }
  2254.     
  2255.     else
  2256.     {
  2257.         if ((errCode = OpenRF((char *) thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,fRefNum)) != noErr)
  2258.         {
  2259.             sprintf(errorMessage,"OpenResourceFork: OpenRF('%s') error %d",theFileName,errCode);
  2260.             goto EXITPOINT;
  2261.         }
  2262.     }
  2263.     
  2264.     if ((errCode = SetFPos(*fRefNum,fsFromStart,0L)) != noErr)
  2265.     {
  2266.         FSClose(*fRefNum);
  2267.         *fRefNum = 0;
  2268.         sprintf(errorMessage,"OpenResourceFork: SetFPos('%s',fsFromStart,0L) error %d",theFileName,errCode);
  2269.         goto EXITPOINT;
  2270.     }
  2271.     
  2272. EXITPOINT:
  2273.  
  2274.     return(errCode);
  2275. }
  2276.  
  2277.  
  2278.  
  2279.  
  2280. int OpenAndZeroDataFork(long theType,long theCreator,sys67SFReply *thesys67SFReply,int *theFRefNum)
  2281. {
  2282. int        errCode;
  2283. char    theFileName[64];
  2284.  
  2285.     *theFRefNum = 0;
  2286.     
  2287.     ExtractSFFileName(thesys67SFReply,theFileName);
  2288.     
  2289.     errCode = OpenDataFork(thesys67SFReply,theFRefNum);
  2290.     
  2291.     if (errCode == fnfErr)
  2292.     {
  2293.         if (hasSys7SFGetPut)
  2294.         {
  2295.             errCode = FSpCreate(&(thesys67SFReply->sys7SFReply.sfFile),theCreator,theType,thesys67SFReply->sys7SFReply.sfScript);
  2296.         }
  2297.         
  2298.         else
  2299.         {
  2300.             errCode = Create(thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,theCreator,theType);
  2301.         }
  2302.             
  2303.         if (errCode != noErr)
  2304.         {
  2305.             sprintf(errorMessage,"OpenAndZeroDataFork: FSpCreate('%s') error %d",theFileName,errCode);
  2306.             *theFRefNum = 0;
  2307.             goto EXITPOINT;
  2308.         }
  2309.         
  2310.         errCode = OpenDataFork(thesys67SFReply,theFRefNum);
  2311.     }
  2312.     
  2313.     if (errCode != noErr)
  2314.         goto EXITPOINT;
  2315.     
  2316.     if ((errCode = SetEOF(*theFRefNum,0L)) != noErr)
  2317.     {
  2318.         FSClose(*theFRefNum);
  2319.         *theFRefNum = 0;
  2320.         sprintf(errorMessage,"OpenAndZeroDataFork: SetEOF('%s',0L) error %d",theFileName,errCode);
  2321.         goto EXITPOINT;
  2322.     }
  2323.     
  2324.     if ((errCode = SetFPos(*theFRefNum,fsFromStart,0L)) != noErr)
  2325.     {
  2326.         FSClose(*theFRefNum);
  2327.         *theFRefNum = 0;
  2328.         sprintf(errorMessage,"OpenAndZeroDataFork: SetFPos('%s',fsFromStart,0L) error %d",theFileName,errCode);
  2329.         goto EXITPOINT;
  2330.     }
  2331.     
  2332. EXITPOINT:
  2333.  
  2334.     return(errCode);
  2335. }
  2336.  
  2337.  
  2338.  
  2339.  
  2340. int OpenAndZeroResourceFork(long theType,long theCreator,sys67SFReply *thesys67SFReply,int *theFRefNum)
  2341. {
  2342. int        errCode;
  2343. char    theFileName[64];
  2344.  
  2345.     *theFRefNum = 0;
  2346.     
  2347.     ExtractSFFileName(thesys67SFReply,theFileName);
  2348.     
  2349.     errCode = OpenResourceFork(thesys67SFReply,theFRefNum);
  2350.     
  2351.     if (errCode == fnfErr)
  2352.     {
  2353.         if (hasSys7SFGetPut)
  2354.         {
  2355.             errCode = FSpCreate(&(thesys67SFReply->sys7SFReply.sfFile),theCreator,theType,thesys67SFReply->sys7SFReply.sfScript);
  2356.         }
  2357.         
  2358.         else
  2359.         {
  2360.             errCode = Create(thesys67SFReply->sys6SFReply.fName,thesys67SFReply->sys6SFReply.vRefNum,theCreator,theType);
  2361.         }
  2362.             
  2363.         if (errCode != noErr)
  2364.         {
  2365.             sprintf(errorMessage,"OpenAndZeroDataFork: FSpCreate('%s') error %d",theFileName,errCode);
  2366.             *theFRefNum = 0;
  2367.             goto EXITPOINT;
  2368.         }
  2369.         
  2370.         errCode = OpenDataFork(thesys67SFReply,theFRefNum);
  2371.     }
  2372.     
  2373.     if (errCode != noErr)
  2374.         goto EXITPOINT;
  2375.     
  2376.     if ((errCode = SetEOF(*theFRefNum,0L)) != noErr)
  2377.     {
  2378.         FSClose(*theFRefNum);
  2379.         *theFRefNum = 0;
  2380.         sprintf(errorMessage,"OpenAndZeroResourceFork: SetEOF('%s',0L) error %d",theFileName,errCode);
  2381.         goto EXITPOINT;
  2382.     }
  2383.     
  2384.     if ((errCode = SetFPos(*theFRefNum,fsFromStart,0L)) != noErr)
  2385.     {
  2386.         FSClose(*theFRefNum);
  2387.         *theFRefNum = 0;
  2388.         sprintf(errorMessage,"OpenAndZeroResourceFork: SetFPos('%s',fsFromStart,0L) error %d",theFileName,errCode);
  2389.         goto EXITPOINT;
  2390.     }
  2391.     
  2392. EXITPOINT:
  2393.  
  2394.     return(errCode);
  2395. }
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401. int LoadDataFork(sys67SFReply *thesys67SFReply,Handle *theDataHandle,long *theDataLength)
  2402. {
  2403. int            errCode,fRefNum;
  2404. long        byteCount;
  2405. char        theFileName[64];
  2406.  
  2407.  
  2408.     errCode = noErr;
  2409.     
  2410.     *theDataHandle = 0L;
  2411.     *theDataLength = 0L;
  2412.     
  2413.     ExtractSFFileName(thesys67SFReply,theFileName);
  2414.     
  2415.     errCode = OpenDataFork(thesys67SFReply,&fRefNum);
  2416.     
  2417.     if (errCode != noErr)
  2418.         goto EXITPOINT;
  2419.     
  2420.     if ((errCode = GetEOF(fRefNum,&byteCount)) != noErr)
  2421.     {
  2422.         FSClose(fRefNum);
  2423.         fRefNum = 0;
  2424.         sprintf(errorMessage,"LoadDataFork: GetEOF('%s') error %d",theFileName,errCode);
  2425.         goto EXITPOINT;
  2426.     }
  2427.     
  2428.     *theDataHandle = NewHandle(byteCount);
  2429.     
  2430.     errCode = MemError();
  2431.     
  2432.     if (*theDataHandle == 0L || errCode != noErr)
  2433.     {
  2434.         *theDataHandle = 0L;
  2435.         *theDataLength = 0L;
  2436.         FSClose(fRefNum);
  2437.         fRefNum = 0;
  2438.         
  2439.         if (errCode == noErr)
  2440.             errCode = memFullErr;
  2441.         
  2442.         sprintf(errorMessage,"LoadDataFork: NewHandle(%ld) error %d",byteCount,errCode);
  2443.         
  2444.         goto EXITPOINT;
  2445.     }
  2446.     
  2447.     
  2448.     *theDataLength = byteCount;
  2449.     
  2450.     HLock(*theDataHandle);
  2451.     
  2452.     if ((errCode = FSRead(fRefNum,theDataLength,**theDataHandle)) != noErr)
  2453.     {
  2454.         DisposHandle(*theDataHandle);
  2455.         *theDataHandle = 0L;
  2456.         *theDataLength = 0L;
  2457.         FSClose(fRefNum);
  2458.         fRefNum = 0;
  2459.         sprintf(errorMessage,"LoadDataFork: FSRead('%s') error %d",theFileName,errCode);
  2460.         goto EXITPOINT;
  2461.     }
  2462.     
  2463.     if ((errCode = FSClose(fRefNum)) != noErr)
  2464.     {
  2465.         DisposHandle(*theDataHandle);
  2466.         *theDataHandle = 0L;
  2467.         *theDataLength = 0L;
  2468.         sprintf(errorMessage,"LoadDataFork: FSClose('%s') error %d",theFileName,errCode);
  2469.         goto EXITPOINT;
  2470.     }
  2471.     
  2472. EXITPOINT:
  2473.     
  2474.     if (*theDataHandle)
  2475.         HUnlock(*theDataHandle);
  2476.     
  2477.     return(errCode);
  2478. }
  2479.  
  2480.  
  2481.  
  2482.  
  2483. int LoadResourceFork(sys67SFReply *thesys67SFReply,Handle *theDataHandle,long *theDataLength)
  2484. {
  2485. int            errCode,fRefNum;
  2486. long        byteCount;
  2487. char        theFileName[64];
  2488.  
  2489.  
  2490.     errCode = noErr;
  2491.     
  2492.     *theDataHandle = 0L;
  2493.     *theDataLength = 0L;
  2494.     
  2495.     ExtractSFFileName(thesys67SFReply,theFileName);
  2496.     
  2497.     errCode = OpenResourceFork(thesys67SFReply,&fRefNum);
  2498.     
  2499.     if (errCode != noErr)
  2500.         goto EXITPOINT;
  2501.     
  2502.     
  2503.     if ((errCode = GetEOF(fRefNum,&byteCount)) != noErr)
  2504.     {
  2505.         FSClose(fRefNum);
  2506.         fRefNum = 0;
  2507.         sprintf(errorMessage,"LoadResourceFork: GetEOF('%s') error %d",theFileName,errCode);
  2508.         goto EXITPOINT;
  2509.     }
  2510.     
  2511.     *theDataHandle = NewHandle(byteCount);
  2512.     
  2513.     errCode = MemError();
  2514.     
  2515.     if (*theDataHandle == 0L || errCode != noErr)
  2516.     {
  2517.         *theDataHandle = 0L;
  2518.         *theDataLength = 0L;
  2519.         
  2520.         FSClose(fRefNum);
  2521.         fRefNum = 0;
  2522.         
  2523.         if (errCode == noErr)
  2524.             errCode = memFullErr;
  2525.         
  2526.         sprintf(errorMessage,"LoadResourceFork: NewHandle(%ld) error %d",byteCount,errCode);
  2527.         
  2528.         goto EXITPOINT;
  2529.     }
  2530.     
  2531.     *theDataLength = byteCount;
  2532.     
  2533.     HLock(*theDataHandle);
  2534.     
  2535.     if ((errCode = FSRead(fRefNum,theDataLength,**theDataHandle)) != noErr)
  2536.     {
  2537.         DisposHandle(*theDataHandle);
  2538.         *theDataHandle = 0L;
  2539.         *theDataLength = 0L;
  2540.         FSClose(fRefNum);
  2541.         fRefNum = 0;
  2542.         sprintf(errorMessage,"LoadResourceFork: FSRead('%s') error %d",theFileName,errCode);
  2543.         goto EXITPOINT;
  2544.     }
  2545.     
  2546.     if ((errCode = FSClose(fRefNum)) != noErr)
  2547.     {
  2548.         DisposHandle(*theDataHandle);
  2549.         *theDataHandle = 0L;
  2550.         *theDataLength = 0L;
  2551.         fRefNum = 0;
  2552.         sprintf(errorMessage,"LoadResourceFork: FSClose('%s') error %d",theFileName,errCode);
  2553.         goto EXITPOINT;
  2554.     }
  2555.     
  2556. EXITPOINT:
  2557.     
  2558.     if (*theDataHandle)
  2559.         HUnlock(*theDataHandle);
  2560.     
  2561.     return(errCode);
  2562. }
  2563.  
  2564.  
  2565.  
  2566.  
  2567. int MakeSys67SFReply(sys67SFReply *thesys67SFReply,char *fName,int vRefNum)
  2568. {
  2569. int        errCode;
  2570. char    tempString[64];
  2571.  
  2572.     errCode = noErr;
  2573.     
  2574.     if (hasSys7Aliases)
  2575.     {
  2576.         mystrncpy(tempString,fName,63);
  2577.         CtoPstr(tempString);
  2578.         
  2579.         errCode = FSMakeFSSpec(vRefNum,0,tempString,&(thesys67SFReply->sys7SFReply.sfFile));
  2580.         
  2581.         if (errCode != noErr)
  2582.             sprintf(errorMessage,"MakeSys67SFReply: FSMakeFSSpec() error %d",errCode);
  2583.     }
  2584.     
  2585.     else
  2586.     {
  2587.         mystrncpy((char *) thesys67SFReply->sys6SFReply.fName,fName,63);
  2588.         CtoPstr((char *) thesys67SFReply->sys6SFReply.fName);
  2589.         
  2590.         thesys67SFReply->sys6SFReply.vRefNum = vRefNum;
  2591.     }
  2592.     
  2593.     return(errCode);
  2594. }
  2595.  
  2596.  
  2597.  
  2598.  
  2599. int Sys67FileExists(sys67SFReply *thesys67SFReply)
  2600. {
  2601. int                errCode;
  2602. long            longDummy;
  2603. unsigned int    intDummy;
  2604.  
  2605.     errCode = GetSFTypeCreatorFlags(thesys67SFReply,&longDummy,&longDummy,&intDummy);
  2606.     
  2607.     
  2608. EXITPOINT:
  2609.     
  2610.     return(errCode);
  2611. }