home *** CD-ROM | disk | FTP | other *** search
- /*
- IC StandardFile.c
-
- */
-
- #include <Finder.h>
- #include <StandardFile.h>
-
- #include "IC Globals.h"
- #include "IC Misc Subs.h"
- #include "IC StandardFile.h"
- #include "StandardGetFolder.h"
-
- OSErr ICStandardGetFile(OSType t,FSSpec* fs,FInfo* fi){
- SFTypeList tl;
- SFReply reply;
- short types;
- OSErr err;
- StandardFileReply nreply;
- long junk;
-
- types=1;
- tl[0]=t;
- if (t==(OSType)0)
- types=-1;
- else if (t=='APPL'){
- tl[1]=kApplicationAliasType;
- types++;
- }
-
- err=userCanceledErr;
-
- if (Has_NewStdFile){
- StandardGetFile((FileFilterUPP)0,types,tl,&nreply);
-
- if (nreply.sfGood){
- BlockMoveData((Ptr)&(nreply.sfFile),(Ptr)fs,sizeof(FSSpec));
- err=HGetFInfo(fs->vRefNum,fs->parID,fs->name,fi);
- }
- } else {
- Point where={0x64,0x64};
-
- SFGetFile(where,"\p",(FileFilterUPP)0,types,tl,(DlgHookUPP)0,&reply);
-
- if (reply.good){
- err=GetFInfo(reply.fName,reply.vRefNum,fi);
- if (err==noErr){
- SetPString(fs->name,1,reply.fName);
- err=GetWDInfo(reply.vRefNum,&(fs->vRefNum),&(fs->parID),&junk);
- }
- }
- }
-
- return err;
- }
-
- OSErr ICStandardPutFile(StringPtr prompt,StringPtr name,FSSpec* fs){
- SFReply reply;
- OSErr err;
- long junk;
- StandardFileReply nreply;
-
- err=userCanceledErr;
-
- if (Has_NewStdFile){
- StandardPutFile(prompt,name,&nreply);
- if (nreply.sfGood){
- BlockMoveData((Ptr)&(nreply.sfFile),(Ptr)fs,sizeof(FSSpec));
- err=noErr;
- }
- } else {
- Point where={0x64,0x64};
-
- SFPutFile(where,prompt,name,(DlgHookUPP)0,&reply);
-
- if (reply.good){
- SetPString(fs->name,1,reply.fName);
- err=GetWDInfo(reply.vRefNum,&(fs->vRefNum),&(fs->parID),&junk);
- }
- }
-
- return err;
- }
-
- pascal short ButtonHook(short item,DialogPtr dlg){
- if (item==11)
- item=sfItemOpenButton;
-
- return item;
- }
-
- OSErr ICStandardGetFolder(FSSpec* fs,long* dirID){
- OSErr err;
- SFTypeList typelist;
- CInfoPBRec cpb;
- SFReply reply;
- long junk;
- StandardFileReply nreply;
- Point where={0x64,0x64};
-
- err=userCanceledErr;
-
- if (Has_NewStdFile){
- StandardGetFolder(where,"\p",&nreply);
- if (nreply.sfGood){
- BlockMoveData((Ptr)&(nreply.sfFile),(Ptr)fs,sizeof(FSSpec));
- err=noErr;
- }
- } else {
- typelist[0]=(OSType)0; // numtypes=0 doesn't seem to stop files from being displayed
-
- SFPGetFile(where,"\p",(FileFilterUPP)0,1,typelist,gButtonHookUPP,&reply,1500,(ModalFilterUPP)0);
-
- if (reply.good){
- err=GetWDInfo(reply.vRefNum,&(fs->vRefNum),&(fs->parID),&junk);
- }
- }
-
- if (err==noErr){
- err=ICFSpGetCatInfo(fs,-1,&cpb);
- if (err==noErr){
- fs->parID=cpb.dirInfo.ioDrParID;
- *dirID=cpb.hFileInfo.ioDirID;
- }
- }
-
- return err;
- }
-
-
-
-