appletfiles.c

Go to the documentation of this file.
00001 
00002 /*  $Id: appletfiles.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /* copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
00005 
00006 
00007 #include <Finder.h>
00008 #include <Script.h>
00009 #include <StandardFile.h>
00010 
00011 #include "appletfiles.h"
00012 #include "appletcursor.h"
00013 #include "appletops.h"
00014 #include "appletmemory.h"
00015 #include "appletstrings.h"
00016 #include "appletbits.h"
00017 #include "appletfilesinternal.h"
00018 #include "appletsyserror.h"
00019 
00020 
00021 
00022 boolean flerrordialogdisabled = false; /*allows high-level code to turn off error dialogs*/
00023 
00024 static OSErr internalerrorcode = noErr;
00025 
00026 #define sfgetfolderid 132
00027 #define sfgetfolderbutton 11
00028 #define sfgetpromptitem 10
00029 
00030 
00031 void setfileerrorfile (ptrfilespec pfs) {
00032     
00033     bigstring fname;
00034     
00035     if (pfs == nil)
00036         setstringlength (fname, 0);
00037     else
00038         filegetfilename (pfs, fname);
00039     
00040     setsyserrorparam (fname);
00041     } /*setfileerrorfile*/
00042     
00043     
00044 boolean fileerror (ptrfilespec pfs, OSErr ec) {
00045     
00046     if (ec == noErr)
00047         return (false);
00048         
00049     internalerrorcode = ec;
00050     
00051     setfileerrorfile (pfs);
00052     
00053     if (flerrordialogdisabled)
00054         return (true);
00055     
00056     return (syserror (ec));
00057     } /*fileerror*/
00058     
00059     
00060 boolean filemakespec (short vnum, long dirid, bigstring fname, ptrfilespec pfs) {
00061 
00062     OSErr ec;
00063     
00064     ec = FSMakeFSSpec (vnum, dirid, fname, pfs);
00065     
00066     return ((ec == noErr) || (ec == fnfErr));
00067     } /*filemakespec*/
00068     
00069     
00070 boolean fileexists (ptrfilespec pfs) {
00071 
00072     FSSpec fs;
00073     
00074     return (FSMakeFSSpec ((*pfs).vRefNum, (*pfs).parID, (*pfs).name, &fs) == noErr);
00075     } /*fileexists*/
00076     
00077 
00078 boolean equalfilespecs (ptrfilespec pfs1, ptrfilespec pfs2) {
00079     
00080     if ((*pfs1).vRefNum != (*pfs2).vRefNum)
00081         return (false);
00082     
00083     if ((*pfs1).parID != (*pfs2).parID)
00084         return (false);
00085         
00086     if (!equalstrings ((*pfs1).name, (*pfs2).name))
00087         return (false);
00088     
00089     return (true);
00090     } /*equalfilespecs*/
00091     
00092 
00093 boolean isvolumefilespec (ptrfilespec pfs) {
00094     
00095     if (((*pfs).parID == 0) && (stringlength ((*pfs).name) == 0))
00096         return (true);
00097         
00098     if ((*pfs).parID == 1) /*added, DW 9/9/93*/
00099         return (true);
00100     
00101     return (false);
00102     } /*isvolumefilespec*/
00103     
00104 
00105 /*
00106 static void convertvolumespec (ptrfilespec pfs) {
00107     
00108     /*
00109     for getting and setting file info only, if we're dealing with a 
00110     volume, convert the file spec to point to the root folder on the
00111     volume. according to Think Reference, (see hint in page for 
00112     PBGetCatInfo) the dirid of the root directory is always 2.
00113     
00114     unfortunately it didn't help. we still can't set the label of
00115     a volume.
00116     
00117     dmb 9/21/93: this is wrong. true, the dirID of the root is 2, but 
00118     if you change that you'd also have to set the name to the empty 
00119     string. there's no reason to do either.
00120     %/
00121     
00122     if (isvolumefilespec (pfs)) 
00123         (*pfs).parID = 2;
00124     } /*convertvolumespec*/
00125     
00126 
00127 boolean getmacfileinfo (ptrfilespec pfs, CInfoPBRec *pb) {
00128     
00129     OSErr ec;
00130     
00131     /*
00132     convertvolumespec (pfs);
00133     */
00134     
00135     clearbytes (pb, longsizeof (*pb));
00136     
00137     (*pb).hFileInfo.ioNamePtr = (*pfs).name;
00138     
00139     (*pb).hFileInfo.ioVRefNum = (*pfs).vRefNum;
00140     
00141     (*pb).hFileInfo.ioDirID = (*pfs).parID;
00142     
00143     ec = PBGetCatInfoSync (pb);
00144     
00145     return (!fileerror (pfs, ec));
00146     } /*getmacfileinfo*/
00147  
00148 
00149 boolean setmacfileinfo (ptrfilespec pfs, CInfoPBRec *pb) {
00150     
00151     OSErr ec;
00152     
00153     /*
00154     convertvolumespec (pfs);
00155     */
00156     
00157     (*pb).hFileInfo.ioNamePtr = (*pfs).name;
00158     
00159     (*pb).hFileInfo.ioVRefNum = (*pfs).vRefNum;
00160     
00161     (*pb).hFileInfo.ioDirID = (*pfs).parID;
00162     
00163     ec = PBSetCatInfoSync (pb);
00164     
00165     return (!fileerror (pfs, ec));
00166     } /*setmacfileinfo*/
00167 
00168 
00169 static boolean getinfofromvolpb (const HVolumeParam *pb, tyfileinfo *info) {
00170     
00171     /*
00172     dmb 9/21/93: for a volume, dirid should be fsRtParID, not fsRtDirID.
00173     */
00174     
00175     short drivenum;
00176     QHdrPtr dqtop;
00177     QElemPtr dqelem;
00178     
00179     clearbytes (info, sizeof (tyfileinfo));
00180     
00181     (*info).vnum = (*pb).ioVRefNum;
00182     
00183     (*info).dirid = fsRtParID; /*fsRtDirID*/
00184     
00185     (*info).flvolume = true;
00186     
00187     (*info).flfolder = true;
00188     
00189     (*info).timecreated = (*pb).ioVCrDate;
00190     
00191     (*info).timemodified = (*pb).ioVLsMod;
00192     
00193     (*info).fllocked = ((*pb).ioVAtrb & 0x8000) != 0;
00194     
00195     (*info).flhardwarelock = ((*pb).ioVAtrb & 0x0080) != 0;
00196     
00197     if ((*info).flhardwarelock)
00198         (*info).fllocked = true;
00199     
00200     (*info).ctfreebytes = (*pb).ioVAlBlkSiz * (*pb).ioVFrBlk;
00201     
00202     (*info).cttotalbytes = (*pb).ioVAlBlkSiz * (*pb).ioVNmAlBlks;
00203     
00204     (*info).ctfiles = (*pb).ioVFilCnt + (*pb).ioVDirCnt;
00205     
00206     drivenum = (*pb).ioVDrvInfo;
00207     
00208     dqtop = GetDrvQHdr ();
00209     
00210     dqelem = (*dqtop).qHead;
00211     
00212     while (true) {
00213         
00214         if (dqelem == nil) { /*volume is no longer in a drive; it must be ejectable!*/
00215             
00216             (*info).flejectable = true;
00217             
00218             break;
00219             }
00220         
00221         if ((*(DrvQEl *)dqelem).dQDrive == drivenum) {
00222             
00223             byte driveflag = *((byte *) dqelem - 3);
00224             
00225             (*info).flejectable = ((driveflag != 8) && (driveflag != 0x48)); /*IM IV-181*/
00226             
00227             break;
00228             }
00229         
00230         dqelem = (*dqelem).qLink;
00231         } /*while*/
00232     
00233     return (true);
00234     } /*getinfofromvolpb*/
00235 
00236 
00237 boolean filegetvolumeinfo (tyvolnum vnum, tyfileinfo *info) {
00238     
00239     /*
00240     dmb 9/21/93: take vnum as parameter, not volname. otherwise, 
00241     we can't distinguish between two vols w/the same name.
00242     */
00243     
00244     HVolumeParam pb;
00245     bigstring bs;
00246     
00247     setemptystring (bs);
00248     
00249     clearbytes (&pb, longsizeof (pb)); /*init all fields to zero*/
00250     
00251     pb.ioVRefNum = vnum;
00252     
00253     pb.ioNamePtr = bs;
00254     
00255     pb.ioVolIndex = -1;
00256     
00257     (*info).errcode = PBHGetVInfoSync ((HParmBlkPtr) &pb);
00258     
00259     clearbytes (info, longsizeof (tyfileinfo)); /*init all fields to zero*/
00260     
00261     if ((*info).errcode != noErr)
00262         return (false);
00263     
00264     getinfofromvolpb (&pb, info);
00265     
00266     /*DW 9/7/93: determine if it's a network volume*/ {
00267         
00268         HParamBlockRec pb;
00269         GetVolParmsInfoBuffer buffer;
00270         OSErr ec;
00271         
00272         clearbytes (&pb, longsizeof (pb)); /*init all fields to zero*/
00273         
00274         pb.ioParam.ioVRefNum = (*info).vnum;
00275         
00276         pb.ioParam.ioBuffer = (Ptr) &buffer;
00277         
00278         pb.ioParam.ioReqCount = longsizeof (buffer);
00279         
00280         ec = PBHGetVolParmsSync (&pb); 
00281     
00282         if (ec == noErr) 
00283             (*info).flremotevolume = buffer.vMServerAdr != 0; /*see Apple TN-Files docviewer doc*/
00284         }
00285     
00286     return (true);
00287     } /*filegetvolumeinfo*/
00288     
00289     
00290 boolean filegetvolumename (short vnum, bigstring volname) {
00291     
00292     HVolumeParam pb;
00293     OSErr ec;
00294     
00295     clearbytes (&pb, longsizeof (pb)); /*init all fields to zero*/
00296     
00297     pb.ioNamePtr = volname;
00298     
00299     pb.ioVolIndex = 0;
00300     
00301     pb.ioVRefNum = vnum;
00302     
00303     ec = PBHGetVInfoSync ((HParmBlkPtr) &pb);
00304     
00305     if (ec != noErr) {
00306         
00307         setstringlength (volname, 0);
00308         
00309         return (false);
00310         }
00311         
00312     return (true);
00313     } /*filegetvolumename*/
00314     
00315     
00316 void filegetinfofrompb (CInfoPBRec *pb, tyfileinfo *info) {
00317     
00318     /*
00319     dmb 9/24/93: handle volumes here, combining vol info with root 
00320     directory folder info. I'm not sure if a volume lock is always 
00321     reflected in the root directory, so don't set fllocked false 
00322     if the attribute isn't set in the pb. (it starts out cleared anyway.)
00323     */
00324     
00325     clearbytes (info, longsizeof (tyfileinfo)); /*init all fields to zero*/
00326     
00327     (*info).vnum = (*pb).hFileInfo.ioVRefNum;
00328     
00329     (*info).dirid = (*pb).hFileInfo.ioFlParID;
00330     
00331     if ((*info).dirid == fsRtParID)
00332         filegetvolumeinfo ((*info).vnum, info);
00333     else
00334         (*info).flvolume = false;
00335     
00336     if (BitTst (&(*pb).dirInfo.ioFlAttrib, 7)) /*if it's a volume, fllocked may already be set*/
00337         (*info).fllocked = true;
00338     
00339     (*info).flfolder = BitTst (&(*pb).dirInfo.ioFlAttrib, 3);
00340     
00341     (*info).ixlabel = ((*pb).hFileInfo.ioFlFndrInfo.fdFlags & 0x000E) >> 1;
00342     
00343     if ((*info).flfolder) {
00344         
00345         (*info).flbusy = (*pb).dirInfo.ioDrNmFls > 0;
00346         
00347         (*info).filecreator = (*info).filetype = '    ';
00348         
00349         if (!(*info).flvolume) { /*these aren't the same for a volume & its root dir*/
00350             
00351             (*info).timecreated = (*pb).dirInfo.ioDrCrDat;
00352             
00353             (*info).timemodified = (*pb).dirInfo.ioDrMdDat;
00354             
00355             (*info).ctfiles = (*pb).dirInfo.ioDrNmFls;
00356             }
00357         
00358         (*info).iconposition = (*pb).dirInfo.ioDrUsrWds.frLocation;
00359         
00360         (*info).folderview = (tyfolderview) ((*pb).dirInfo.ioDrUsrWds.frView >> 8);
00361         }
00362     else { /*fill in fields for a file, somewhat different format than a folder*/
00363     
00364         (*info).flbusy = BitTst (&(*pb).hFileInfo.ioFlAttrib, 0);
00365             
00366         (*info).filecreator = (*pb).hFileInfo.ioFlFndrInfo.fdCreator;
00367         
00368         (*info).filetype = (*pb).hFileInfo.ioFlFndrInfo.fdType;
00369         
00370         (*info).timecreated = (*pb).hFileInfo.ioFlCrDat;
00371 
00372         (*info).timemodified = (*pb).hFileInfo.ioFlMdDat;
00373         
00374         (*info).sizedatafork = (*pb).hFileInfo.ioFlLgLen;
00375         
00376         (*info).sizeresourcefork = (*pb).hFileInfo.ioFlRLgLen;
00377         
00378         (*info).iconposition = (*pb).hFileInfo.ioFlFndrInfo.fdLocation;
00379 
00380         /*copy from the finder bits into the record*/ {
00381         
00382             short finderbits = (*pb).hFileInfo.ioFlFndrInfo.fdFlags;
00383             
00384             (*info).flalias = (finderbits & kIsAlias) != 0;
00385             
00386             (*info).flbundle = (finderbits & kHasBundle) != 0;
00387             
00388             (*info).flinvisible = (finderbits & kIsInvisible) != 0;
00389             
00390             (*info).flstationery = (finderbits & kIsStationary) != 0;
00391             
00392             (*info).flshared = (finderbits & kIsShared) != 0;
00393             
00394             (*info).flnamelocked = (finderbits & kNameLocked) != 0;
00395             
00396             (*info).flcustomicon = (finderbits & kHasCustomIcon) != 0;
00397             }
00398         }
00399     } /*filegetinfofrompb*/
00400     
00401     
00402 boolean filegetinfo (ptrfilespec pfs, tyfileinfo *info) {
00403     
00404     /*
00405     dmb 9/24/93: let filegetinfofrompb take care of volumes
00406     */
00407     
00408     CInfoPBRec pb;
00409     
00410     /*
00411     if (isvolumefilespec (pfs)) {
00412         
00413         return (filegetvolumeinfo ((*pfs).vRefNum, info));
00414         }
00415     */
00416         
00417     if (!getmacfileinfo (pfs, &pb)) {
00418         
00419         clearbytes (info, longsizeof (tyfileinfo)); /*init all fields to zero*/
00420     
00421         (*info).errcode = internalerrorcode;
00422         
00423         return (false);
00424         }
00425     
00426     filegetinfofrompb (&pb, info);
00427     
00428     return (true);
00429     } /*filegetinfo*/
00430     
00431     
00432 boolean filegetfilename (FSSpec *pfs, bigstring name) {
00433     
00434     /*
00435     filespecs for volumes have their strings set to the empty string.
00436     */
00437     
00438     copystring ((*pfs).name, name);
00439     
00440     if (stringlength (name) > 0)
00441         return (true);
00442         
00443     return (filegetvolumename ((*pfs).vRefNum, name));
00444     } /*filegetfilename*/
00445     
00446     
00447 boolean filesettype (ptrfilespec pfs, OSType type) {
00448     
00449     FInfo info;
00450     OSErr ec;
00451     
00452     ec = FSpGetFInfo (pfs, &info);
00453     
00454     if (fileerror (pfs, ec))
00455         return (false);
00456     
00457     info.fdType = type;
00458     
00459     ec = FSpSetFInfo (pfs, &info);
00460     
00461     return (!fileerror (pfs, ec));
00462     } /*filesettype*/
00463     
00464     
00465 boolean filesetcreator (ptrfilespec pfs, OSType creator) {
00466     
00467     FInfo info;
00468     OSErr ec;
00469     
00470     ec = FSpGetFInfo (pfs, &info);
00471     
00472     if (fileerror (pfs, ec))
00473         return (false);
00474     
00475     info.fdCreator = creator;
00476     
00477     ec = FSpSetFInfo (pfs, &info);
00478     
00479     return (!fileerror (pfs, ec));
00480     } /*filesetcreator*/
00481     
00482     
00483 void fileclose (short fnum) {
00484     
00485     if (fnum != 0)
00486         FSClose (fnum);
00487     } /*fileclose*/
00488     
00489 
00490 boolean fileseteof (short fnum, long eof) {
00491     
00492     OSErr errcode;
00493     
00494     if (fnum != 0) {
00495     
00496         errcode = SetEOF (fnum, eof);
00497         
00498         return (errcode == noErr);
00499         }
00500         
00501     return (true);
00502     } /*fileseteof*/
00503     
00504 
00505 boolean fileopen (ptrfilespec pfs, short *fnum) {
00506     
00507     OSErr ec;
00508     
00509     setfileerrorfile (pfs); /*set name for read/write ops that only know about fnums*/
00510     
00511     ec = FSpOpenDF (pfs, fsCurPerm, fnum);
00512 
00513     return (!fileerror (pfs, ec));
00514     } /*fileopen*/
00515     
00516     
00517 boolean fileopenforreading (ptrfilespec pfs, short *fnum) {
00518     
00519     OSErr ec;
00520     
00521     setfileerrorfile (pfs); /*set name for read/write ops that only know about fnums*/
00522     
00523     ec = FSpOpenDF (pfs, fsRdPerm, fnum);
00524 
00525     return (!fileerror (pfs, ec));
00526     } /*fileopenforreading*/
00527     
00528     
00529 boolean fileopenresourcefork (ptrfilespec pfs, short *fnum) {
00530     
00531     OSErr ec;
00532     
00533     setfileerrorfile (pfs); /*set name for read/write ops that only know about fnums*/
00534     
00535     ec = FSpOpenRF (pfs, fsCurPerm, fnum);
00536 
00537     return (!fileerror (pfs, ec));
00538     } /*fileopenresourcefork*/
00539     
00540     
00541 boolean filedeletefile (ptrfilespec pfs) {
00542     
00543     /*
00544     we just delete files, not folders
00545     */
00546         
00547     OSErr ec;
00548     
00549     setfileerrorfile (pfs); /*set name for read/write ops that only know about fnums*/
00550     
00551     ec = FSpDelete (pfs);
00552 
00553     return (!fileerror (pfs, ec));
00554     } /*filedeletefile*/
00555     
00556     
00557 boolean filenew (ptrfilespec pfs, OSType creator, OSType filetype, short *fnum) {
00558     
00559     OSErr errcode;
00560 
00561     setfileerrorfile (pfs); /*set name for read/write ops that only know about fnums*/
00562     
00563     if (FSpOpenDF (pfs, fsCurPerm, fnum) == noErr) { /*file exists, delete it*/
00564     
00565         FSClose (*fnum);
00566     
00567         filedeletefile (pfs);
00568         }
00569         
00570     errcode = FSpCreate (pfs, creator, filetype, smSystemScript);
00571     
00572     if (fileerror (pfs, errcode)) /*failed to open the file for writing*/
00573         return (false);
00574     
00575     errcode = FSpOpenDF (pfs, fsCurPerm, fnum);
00576     
00577     if (fileerror (pfs, errcode)) {
00578     
00579         FSClose (*fnum);
00580             
00581         filedeletefile (pfs);
00582         
00583         return (false); /*failed to open the file for writing*/
00584         }
00585         
00586     return (true); /*file exists and its open*/
00587     } /*filenew*/
00588     
00589     
00590 boolean filetruncate (short fnum) {
00591     
00592     return (!fileerror (nil, SetEOF (fnum, 0)));
00593     } /*filetruncate*/
00594 
00595 
00596 long filegetsize (short fnum) {
00597     
00598     /*
00599     get the size of a file that's already open.
00600     */
00601     
00602     long filesize;
00603     
00604     if (GetEOF (fnum, &filesize) != noErr)
00605         filesize = 0;
00606     
00607     return (filesize);
00608     } /*filegetsize*/
00609 
00610 
00611 boolean filewrite (short fnum, long ctwrite, void *buffer) {
00612     
00613     /*
00614     write ctwrite bytes from buffer to the current position in file number
00615     fnum.  return true iff successful.
00616     */
00617 
00618     if (ctwrite > 0) {
00619 
00620         if (fileerror (nil, FSWrite (fnum, &ctwrite, buffer)))
00621         
00622             return (false);
00623         }
00624     
00625     return (true);
00626     } /*filewrite*/
00627     
00628     
00629 boolean fileread (short fnum, long ctread, void *buffer) {
00630     
00631     /*
00632     read ctread bytes from the current position in file number fnum into
00633     the buffer.  return true iff successful.
00634     */
00635 
00636     if (ctread > 0) {
00637         
00638         if (fileerror (nil, FSRead (fnum, &ctread, buffer)))
00639         
00640             return (false);
00641         }
00642             
00643     return (true);
00644     } /*fileread*/
00645     
00646     
00647 boolean filegetchar (short fnum, byte *buffer) {
00648     
00649     /*
00650     read the next character from the indicated file, returning it in *buffer.
00651     
00652     return false if we're at the end of the file, without triggering an error
00653     dialog.
00654     */
00655     
00656     long fpos, eof;
00657     
00658     if (GetFPos (fnum, &fpos) != noErr)
00659         return (false);
00660     
00661     if (GetEOF (fnum, &eof) != noErr)
00662         return (false);
00663     
00664     if (fpos == eof)
00665         return (false);
00666     
00667     if (!fileread (fnum, 1L, buffer))
00668         return (false);
00669         
00670     return (true);
00671     } /*filegetchar*/
00672     
00673     
00674 boolean filewritehandle (short fnum, Handle h) {
00675     
00676     /*
00677     write the indicated handle to the open file indicated by fnum at the
00678     current position in the file.
00679     */
00680     
00681     boolean fl;
00682     
00683     HLock (h);
00684     
00685     fl = filewrite (fnum, GetHandleSize (h), *h);
00686     
00687     HUnlock (h);
00688     
00689     return (fl);
00690     } /*filewritehandle*/
00691     
00692     
00693 boolean filereadhandle (short fnum, long ctbytes, Handle *hreturned) {
00694     
00695     Handle h;
00696     boolean fl;
00697     long filesize;
00698     
00699     filesize = filegetsize (fnum);
00700     
00701     if (ctbytes > filesize)
00702         ctbytes = filesize;
00703     
00704     if (!newclearhandle (ctbytes, hreturned))
00705         return (false);
00706         
00707     h = *hreturned; /*copy into register*/
00708     
00709     lockhandle (h);
00710     
00711     fl = fileread (fnum, ctbytes, *h);
00712     
00713     unlockhandle (h);
00714         
00715     if (!fl) {
00716         
00717         disposehandle (h);
00718         
00719         *hreturned = nil;
00720         
00721         return (false);
00722         }
00723         
00724     return (true);
00725     } /*filereadhandle*/    
00726 
00727 
00728 boolean filereadwholefile (short fnum, Handle *hreturned) {
00729     
00730     /*
00731     load the whole file into memory, return true if it worked, with
00732     the handle holding all the data from the file.
00733     */
00734     
00735     return (filereadhandle (fnum, filegetsize (fnum), hreturned));
00736     } /*filereadwholefile*/
00737 
00738     
00739 static sfcallback sfglobalfilter = nil;
00740 
00741 
00742 static pascal Boolean sffilter (CInfoPBRec *pb) {
00743     
00744     /*
00745     if we return true, the file is filtered, meaning it is not included in the
00746     standard file dialog list.
00747     */
00748     
00749     tyfileinfo info;
00750     
00751     if (sfglobalfilter == nil)
00752         return (-1);
00753         
00754     filegetinfofrompb (pb, &info);
00755     
00756     if ((*sfglobalfilter) (&info))
00757         return (-1);
00758         
00759     return (0);
00760     } /*sffilter*/
00761 
00762 
00763 #if GENERATINGCFM
00764 
00765     static RoutineDescriptor sffilterDesc = BUILD_ROUTINE_DESCRIPTOR (uppFileFilterProcInfo, sffilter);
00766 
00767     #define sffilterUPP ((FileFilterUPP) &sffilterDesc)
00768 
00769 #else
00770 
00771     #define sffilterUPP ((FileFilterUPP) &sffilter)
00772 
00773 #endif
00774 
00775 
00776 boolean sfdialog (boolean flput, bigstring prompt, ptrfilespec pfs, sfcallback filterproc, OSType filetype) {
00777     
00778     DialogTHndl hdialog;
00779     short id;
00780     Rect r, rscreen;
00781     Point pt;
00782     SFReply reply;
00783     SFTypeList typesrec;
00784 
00785     cometofront ();
00786     
00787     arrowcursor ();
00788     
00789     if (flput)
00790         id = getDlgID;
00791     else
00792         id = putDlgID;
00793         
00794     hdialog = (DialogTHndl) GetResource ('DLOG', id);
00795     
00796     if (hdialog == nil) {
00797         
00798         pt.h = pt.v = 85;
00799         }
00800     else {
00801         r = (**hdialog).boundsRect;
00802     
00803         rscreen = quickdrawglobal (screenBits).bounds;
00804     
00805         pt.h = rscreen.left + (((rscreen.right - rscreen.left) - (r.right - r.left)) / 2);
00806     
00807         pt.v = rscreen.top + ((rscreen.bottom - rscreen.top) - (r.bottom - r.top)) / 3;
00808         }
00809 
00810     if (flput)
00811         SFPutFile (pt, prompt, (*pfs).name, nil, &reply);
00812         
00813     else {
00814         if (filterproc == nil) {
00815         
00816             short ctfiles;
00817             
00818             if (filetype == 0) /*set filetype to 0 to get all files*/
00819                 ctfiles = -1;
00820             else {
00821                 ctfiles = 1;
00822                 
00823                 typesrec [0] = filetype;
00824                 }
00825             
00826             SFGetFile (pt, prompt, nil, ctfiles, typesrec, nil, &reply);
00827             }
00828         else {  
00829             sfglobalfilter = filterproc;
00830         
00831             SFGetFile (pt, prompt, sffilterUPP, -1, typesrec, nil, &reply);
00832             }
00833         }
00834         
00835     if (reply.good) {
00836         
00837         clearbytes (pfs, longsizeof (tyfilespec));
00838         
00839         (*pfs).vRefNum = reply.vRefNum;
00840         
00841         copystring (reply.fName, (*pfs).name);
00842         }
00843         
00844     return (reply.good);
00845     } /*sfdialog*/
00846 

Generated on Wed May 31 18:19:41 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6