home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c063 / 3.ddi / CLASSEXM.ZIP / DIRECTRY.CPP next >
Encoding:
C/C++ Source or Header  |  1992-02-18  |  1.4 KB  |  64 lines

  1. #if !defined( __SORTARRY_H )
  2. #include <SortArry.h>
  3. #endif  // __SORTARRY_H
  4.  
  5. #ifndef __DIR_H
  6. #include <dir.h>
  7. #define __DIR_H
  8. #endif
  9.  
  10. #ifndef __DIRECTRY_H
  11. #include "directry.h"
  12. #endif
  13.  
  14. #ifndef __FILEDATA_H
  15. #include "filedata.h"
  16. #endif
  17.  
  18. #if !defined( __IOSTREAM_H )
  19. #include <iostream.h>
  20. #endif    // __IOSTREAM_H
  21.  
  22. Directory::Directory( char *pathName, sortOrder sortBy ) :
  23.     SortedArray( 10, 0, 5 ), mask( pathName )
  24. {
  25.     struct ffblk fileBlock;
  26.     int morePathNames = !findfirst( mask, &fileBlock, 0 );
  27.     while( morePathNames )
  28.         {
  29.         addFile( fileBlock, sortBy );
  30.         morePathNames = !findnext( &fileBlock );
  31.         } 
  32. }
  33.  
  34. void Directory::addFile( ffblk& fileBlock, sortOrder sortBy )
  35. {
  36.     switch( sortBy )
  37.         {
  38.         case byName:
  39.             add( *(new FilesByName( fileBlock )) );
  40.             break;
  41.         case byDate:
  42.             add( *(new FilesByDate( fileBlock )) );
  43.             break;
  44.         case bySize:
  45.             add( *(new FilesBySize( fileBlock )) );
  46.             break;
  47.         }
  48. }
  49.  
  50. void Directory::printHeader( ostream& outputStream ) const
  51. {
  52.     outputStream << "Directory: " << mask << "\n    ";
  53. }
  54.  
  55. void Directory::printSeparator( ostream& outputStream ) const
  56. {
  57.     outputStream << "\n    ";
  58. }
  59.  
  60. void Directory::printTrailer( ostream& outputStream ) const
  61. {
  62.     outputStream << "\n";
  63. }
  64.