home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / C Internet Config / IC Application Source ƒ / C Source ƒ / IC StandardFile.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-01  |  2.5 KB  |  132 lines  |  [TEXT/SPM ]

  1. /*
  2.     IC StandardFile.c
  3.     
  4. */
  5.  
  6. #include <Finder.h>
  7. #include <StandardFile.h>
  8.  
  9. #include "IC Globals.h"
  10. #include "IC Misc Subs.h"
  11. #include "IC StandardFile.h"
  12. #include "StandardGetFolder.h"
  13.  
  14. OSErr ICStandardGetFile(OSType t,FSSpec* fs,FInfo* fi){
  15.     SFTypeList tl;
  16.     SFReply reply;
  17.     short types;
  18.     OSErr err;
  19.     StandardFileReply nreply;
  20.     long junk;
  21.     
  22.     types=1;
  23.     tl[0]=t;
  24.     if (t==(OSType)0)
  25.         types=-1;
  26.     else if (t=='APPL'){
  27.         tl[1]=kApplicationAliasType;
  28.         types++;
  29.     }
  30.     
  31.     err=userCanceledErr;
  32.     
  33.     if (Has_NewStdFile){
  34.         StandardGetFile((FileFilterUPP)0,types,tl,&nreply);
  35.         
  36.         if (nreply.sfGood){
  37.             BlockMoveData((Ptr)&(nreply.sfFile),(Ptr)fs,sizeof(FSSpec));
  38.             err=HGetFInfo(fs->vRefNum,fs->parID,fs->name,fi);
  39.         }
  40.     } else {
  41.         Point where={0x64,0x64};
  42.         
  43.         SFGetFile(where,"\p",(FileFilterUPP)0,types,tl,(DlgHookUPP)0,&reply);
  44.         
  45.         if (reply.good){
  46.             err=GetFInfo(reply.fName,reply.vRefNum,fi);
  47.             if (err==noErr){
  48.                 SetPString(fs->name,1,reply.fName);
  49.                 err=GetWDInfo(reply.vRefNum,&(fs->vRefNum),&(fs->parID),&junk);
  50.             }
  51.         }
  52.     }
  53.     
  54.     return err;
  55. }
  56.  
  57. OSErr ICStandardPutFile(StringPtr prompt,StringPtr name,FSSpec* fs){
  58.     SFReply reply;
  59.     OSErr err;
  60.     long junk;
  61.     StandardFileReply nreply;
  62.     
  63.     err=userCanceledErr;
  64.     
  65.     if (Has_NewStdFile){
  66.         StandardPutFile(prompt,name,&nreply);
  67.         if (nreply.sfGood){
  68.             BlockMoveData((Ptr)&(nreply.sfFile),(Ptr)fs,sizeof(FSSpec));
  69.             err=noErr;
  70.         }
  71.     } else {
  72.         Point where={0x64,0x64};
  73.         
  74.         SFPutFile(where,prompt,name,(DlgHookUPP)0,&reply);
  75.         
  76.         if (reply.good){
  77.             SetPString(fs->name,1,reply.fName);
  78.             err=GetWDInfo(reply.vRefNum,&(fs->vRefNum),&(fs->parID),&junk);
  79.         }
  80.     }
  81.     
  82.     return err;
  83. }
  84.  
  85. pascal short ButtonHook(short item,DialogPtr dlg){
  86.     if (item==11)
  87.         item=sfItemOpenButton;
  88.     
  89.     return item;
  90. }
  91.  
  92. OSErr ICStandardGetFolder(FSSpec* fs,long* dirID){
  93.     OSErr err;
  94.     SFTypeList typelist;
  95.     CInfoPBRec cpb;
  96.     SFReply reply;
  97.     long junk;
  98.     StandardFileReply nreply;
  99.     Point where={0x64,0x64};
  100.     
  101.     err=userCanceledErr;
  102.     
  103.     if (Has_NewStdFile){
  104.         StandardGetFolder(where,"\p",&nreply);
  105.         if (nreply.sfGood){
  106.             BlockMoveData((Ptr)&(nreply.sfFile),(Ptr)fs,sizeof(FSSpec));
  107.             err=noErr;
  108.         }
  109.     } else {
  110.         typelist[0]=(OSType)0; // numtypes=0 doesn't seem to stop files from being displayed
  111.         
  112.         SFPGetFile(where,"\p",(FileFilterUPP)0,1,typelist,gButtonHookUPP,&reply,1500,(ModalFilterUPP)0);
  113.         
  114.         if (reply.good){
  115.             err=GetWDInfo(reply.vRefNum,&(fs->vRefNum),&(fs->parID),&junk);
  116.         }
  117.     }
  118.     
  119.     if (err==noErr){
  120.         err=ICFSpGetCatInfo(fs,-1,&cpb);
  121.         if (err==noErr){
  122.             fs->parID=cpb.dirInfo.ioDrParID;
  123.             *dirID=cpb.hFileInfo.ioDirID;
  124.         }
  125.     }
  126.     
  127.     return err;
  128. }
  129.  
  130.  
  131.  
  132.