home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / c_sfsetd.sit < prev    next >
Encoding:
Text File  |  1988-06-20  |  2.2 KB  |  73 lines

  1. 18-Jun-88 14:39:26-MDT,2328;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:39:21 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA22557; Sat, 18 Jun 88 14:39:19 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA24733; Sat, 18 Jun 88 14:39:17 MDT
  8. Date: Sat, 18 Jun 88 14:39:17 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8806182039.AA24733@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: SFSetDir.c
  13.  
  14. /****************************************************************
  15.  * "SFSetDir.c" - Set SFGet/PutFile directory.                    *
  16.  *                                                                *
  17.  *    This routine sets the directory to which the next SFGet or    *
  18.  *    SFPut file call will open.  It works under MFS and HFS.        *
  19.  *                                                                *
  20.  *    Author: Dave Warker (who is Wombat Software)                *
  21.  *    CompuServe: 70406,626                                        *
  22.  *    Delphi: DAVEWARKER                                            *
  23.  *                                                                *
  24.  * 17-Mar-88 dww    Module created.                                *
  25.  ****************************************************************/
  26.  
  27. #include <FileMgr.h>
  28. #include <Hfs.h>
  29. #include <StdFilePkg.h>
  30.  
  31. void SFSetDir(theDir, tryProc)
  32.     int theDir;        /* volume reference or working directory ref num */
  33.     OSType tryProc;    /* set to non-zero to try this WFD proc ID first */
  34.     /*
  35.      * Set directory for next SFGet or SFPut file.
  36.      * You should normally set "tryProc" to 0L unless you have explicitly
  37.      * opened a working directory and want to try to match it exactly
  38.      * before trying the general pool of working directories.
  39.      */
  40. {
  41.     /* assume MFS or not working directory ID */
  42.     SFSaveDisk = -theDir;
  43.  
  44.     if (FSFCBLen > 0)
  45.     {
  46.         /* HFS available, may be working directory */
  47.         WDPBRec wdinfo;
  48.  
  49.         wdinfo.ioCompletion = 0L;
  50.         wdinfo.ioVRefNum = theDir;
  51.         wdinfo.ioWDIndex = 0;
  52.         wdinfo.ioWDVRefNum = 0;
  53.  
  54.         /* try for working directory with requested proc ID */
  55.         wdinfo.ioWDProcID = tryProc;
  56.         if (PBGetWDInfo(&wdinfo, FALSE) != noErr)
  57.         {
  58.             /* failed, try for any proc ID */
  59.             wdinfo.ioWDProcID = 0;
  60.             if (PBGetWDInfo(&wdinfo, FALSE) != noErr)
  61.             {
  62.                 /* that failed too, assume it is a volume ref */
  63.                 CurDirStore = 0;
  64.                 return;
  65.             }
  66.         }
  67.  
  68.         /* we have info for this working ID, setup for SF(Get/Put)File */
  69.         SFSaveDisk = -wdinfo.ioWDVRefNum;
  70.         CurDirStore = wdinfo.ioWDDirID;
  71.     }
  72. }
  73.