home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / UGetMultipleFiles 1.4 / GetDirItems.c < prev    next >
Encoding:
Text File  |  1996-08-13  |  2.5 KB  |  90 lines  |  [TEXT/CWIE]

  1. // --------------------------------------------------------------------------------------------
  2. //    UGetMulltipleFiles - An Add Files utility class
  3. //        By David Hirsch
  4. // --------------------------------------------------------------------------------------------
  5.  
  6. // GetDirItems.c - taken from the following source, with changes.
  7.  
  8.     /*
  9.     **    Apple Macintosh Developer Technical Support
  10.     **
  11.     **    A collection of useful high-level File Manager routines.
  12.     **
  13.     **    by Jim Luther, Apple Developer Technical Support Emeritus
  14.     **
  15.     **    File:        MoreFilesExtras.c
  16.     **
  17.     **    Copyright © 1992-1996 Apple Computer, Inc.
  18.     **    All rights reserved.
  19.     **
  20.     **    You may incorporate this sample code into your applications without
  21.     **    restriction, though the sample code has been provided "AS IS" and the
  22.     **    responsibility for its operation is 100% yours.  However, what you are
  23.     **    not permitted to do is to redistribute the source as "DSC Sample Code"
  24.     **    after having made changes. If you're going to re-distribute the source,
  25.     **    we require that you make it clear in the source that the code was
  26.     **    descended from Apple Sample Code, but that you've made changes.
  27.     */
  28.  
  29.  
  30. #include "GetDirItems.h"
  31.  
  32. /*****************************************************************************/
  33.  
  34. pascal    OSErr    GetDirItems(short vRefNum,
  35.                             long dirID,
  36.                             StringPtr,
  37.                             Boolean getFiles,
  38.                             Boolean getDirectories,
  39.                             FSSpecPtr items,
  40.                             short reqItemCount,
  41.                             short *actItemCount,
  42.                             short *itemIndex) /* start with 1, then use what's returned */
  43. {
  44.     CInfoPBRec pb;
  45.     OSErr error = noErr;
  46.     long theDirID;
  47.     FSSpec *endItemsArray = items + reqItemCount;
  48.     
  49.     if ( *itemIndex <= 0 )
  50.         return ( paramErr );
  51.     
  52.     pb.hFileInfo.ioVRefNum =     vRefNum;
  53.     theDirID = dirID;
  54.  
  55.     *actItemCount = 0;
  56.     for ( ; (items < endItemsArray) && (error == noErr); )
  57.     {
  58.         pb.hFileInfo.ioNamePtr = (StringPtr) &items->name;
  59.         pb.hFileInfo.ioDirID = theDirID;
  60.         pb.hFileInfo.ioFDirIndex = *itemIndex;
  61.         error = PBGetCatInfoSync(&pb);
  62.         if ( error == noErr )
  63.         {
  64.             items->parID = pb.hFileInfo.ioFlParID;    /* return item's parID */
  65.             items->vRefNum = pb.hFileInfo.ioVRefNum;    /* return item's vRefNum */
  66.             ++*itemIndex;    /* prepare to get next item in directory */
  67.             
  68.             if ( (pb.hFileInfo.ioFlAttrib & ioDirMask) != 0 )
  69.             {
  70.                 if ( getDirectories )
  71.                 {
  72.                     ++*actItemCount; /* keep this item */
  73.                     ++items; /* point to next item */
  74.                 }
  75.             }
  76.             else
  77.             {
  78.                 if ( getFiles )
  79.                 {
  80.                     ++*actItemCount; /* keep this item */
  81.                     ++items; /* point to next item */
  82.                 }
  83.             }
  84.         }
  85.     }
  86.     return ( error );
  87. }
  88.  
  89.  
  90.