home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c063 / 3.ddi / CLASSEXM.ZIP / TESTDIR.CPP < prev   
Encoding:
C/C++ Source or Header  |  1992-02-18  |  1.1 KB  |  45 lines

  1. #ifndef __STDLIB_H
  2. #include <stdlib.h>
  3. #endif
  4.  
  5. #ifndef __IOSTREAM_H
  6. #include <iostream.h>
  7. #endif
  8.  
  9. #ifndef __DIRECTRY_H
  10. #include "directry.h"
  11. #endif
  12.  
  13. int main( int argc, char *argv[] )
  14. {
  15.     if( argc < 2 || argc > 3 )
  16.         {
  17.         cerr << "Usage:  directry [options] filespec" << endl << endl;
  18.         cerr << "Options:" << endl;
  19.         cerr << "\t-sd\tsort by date" << endl;
  20.         cerr << "\t-sn\tsort by name" << endl;
  21.         cerr << "\t-ss\tsort by size" << endl;
  22.         exit(1);
  23.         }
  24.  
  25.     int path;                       
  26.     Directory::sortOrder sorting = Directory::byName;
  27.  
  28.     if( argc != 3 )
  29.         path = 1;
  30.     else 
  31.         {
  32.         path = 2;
  33.         if( strcmp( argv[1], "-sn" ) == 0 )
  34.             sorting = Directory::byName;
  35.         else if( strcmp( argv[1], "-sd" ) == 0 )
  36.             sorting = Directory::byDate;
  37.         else if( strcmp( argv[1], "-ss" ) == 0 )
  38.             sorting = Directory::bySize;
  39.         }
  40.  
  41.     Directory sortedDirectory( argv[path], sorting );
  42.     cout << sortedDirectory;
  43.     return 0;
  44. }
  45.