home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CNEWS018.ZIP / DL.ZIP / DL.HPP < prev   
C/C++ Source or Header  |  1989-12-17  |  8KB  |  229 lines

  1. //////////////////////////////////////////////////////////
  2. //                                                      //
  3. //           ******************************             //
  4. //           ****  Browning's Classes  ****             //
  5. //           ******************************             //
  6. //                                                      //
  7. //                  Class DL_3.Hpp                      //
  8. //                                                      //
  9. //       Public Domain           Roy G. Browning        //
  10. //       December 1989           The Fulcrum's Edge     //
  11. //                                                      //
  12. //       Zortech C/C++           version 2.01           //
  13. //                                                      //
  14. //       Ztc -o -mti DL_3                               //
  15. //                                                      //
  16. //       Initiated               05-01-1989             //
  17. //////////////////////////////////////////////////////////
  18.  
  19. //////////////////////////////////////////////////////////
  20. //                                                      //
  21. //                   Charity Request                    //
  22. //                                                      //
  23. //       If benefit is derived in any fashion from      //
  24. //       this public code it is requested that a        //
  25. //       donation be made to a children's charity       //
  26. //       if sufficient funds are available.             //
  27. //                                                      //
  28. //////////////////////////////////////////////////////////
  29.  
  30. //////////////////////////////////////////////////////////
  31. //                                                      //
  32. //                  C++ing How Series                   //
  33. //                                                      //
  34. //////////////////////////////////////////////////////////
  35.  
  36. #include <stream.hpp>
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <ctype.h>
  41. #include <dos.h>
  42.  
  43. #define MAXFILES 2048
  44.  
  45. extern "C" {
  46.             extern int Cmp_FileName(const FIND **p1,
  47.                                     const FIND **p2);
  48.             extern int Cmp_FileExt(const FIND **p1,
  49.                                    const FIND **p2);
  50.             extern int Cmp_FileDate(const FIND **p1,
  51.                                     const FIND **p2);
  52.             extern int Cmp_FileSize(const FIND **p1,
  53.                                     const FIND **p2);
  54.            };
  55.  
  56. extern void First_Object();
  57. extern void Second_Object();
  58. extern void Third_Object();
  59. extern void Fourth_Object();
  60.  
  61. enum logic {
  62.             error = (-1),
  63.             false,
  64.             true
  65.            };
  66.  
  67. enum numbers {
  68.               minusone = (-1),
  69.               zero,
  70.               one,
  71.               two,
  72.               three,
  73.               four,
  74.               five,
  75.               six,
  76.               seven,
  77.               eight,
  78.               nine,
  79.               ten,
  80.               eleven,
  81.               twelve
  82.              };
  83.  
  84. // Directory entry attributes
  85.  
  86. //      FA_RDONLY      0x01
  87. //      FA_HIDDEN      0x02
  88. //      FA_SYSTEM      0x04
  89. //      FA_LABEL       0x08
  90. //      FA_DIREC       0x10
  91. //      FA_ARCH        0x20
  92.  
  93.  
  94. //////////////////////////////////////////////////////////
  95. //                                                      //
  96. //                   Class FileList                     //
  97. //                                                      //
  98. //       Reads and stores a disk directory in an        //
  99. //       array of structure pointers.  The default      //
  100. //       arguments are used if none are specified       //
  101. //       when the class is created.                     //
  102. //                                                      //
  103. //       If `num_files' equals minus one an error       //
  104. //       occurred.                                      //
  105. //                                                      //
  106. //       Element()  returns a reference to the          //
  107. //                  element number indicated            //
  108. //                  by the index passed                 //
  109. //                                                      //
  110. //       FileName_Match()     returns a pointer to      //
  111. //                            an index array of         //
  112. //                            matching directory        //
  113. //                            FileNames                 //
  114. //                                                      //
  115. //       Number()   returns the number of files         //
  116. //                  listed                              //
  117. //                                                      //
  118. //       Print()    prints a formatted directory        //
  119. //                  listing to the stdout (display)     //
  120. //                                                      //
  121. //////////////////////////////////////////////////////////
  122.  
  123. class FileList {
  124.  
  125. protected:
  126.  
  127.      int num_files;
  128.      int *match_numbers;
  129.      int match_numbers_allocated;
  130.  
  131.      FIND **F;
  132.  
  133. public:
  134.  
  135.      FileList(const char* name = "*.*",
  136.               const int attrib = zero);
  137.  
  138.      ~FileList();
  139.  
  140.      FIND& Element(const int i) const { return *F[i]; }
  141.  
  142.      int* FileName_Match(char* string = NULL) const;
  143.  
  144.      int Number() const { return num_files; } 
  145.  
  146.      void Print() const;
  147. };
  148.  
  149. //////////////////////////////////////////////////////////
  150. //                                                      //
  151. //                   Class FileName                     //
  152. //                                                      //
  153. //       "Derived" from FileList which is con-          //
  154. //       structed prior to sorting the directory        //
  155. //       listing via File Names.  The default argu-     //
  156. //       ments are used if none are given.              //
  157. //                                                      //
  158. //////////////////////////////////////////////////////////
  159.  
  160. class FileName : public FileList {
  161.  
  162. public:
  163.  
  164.      FileName(const char* = "*.*", const int = zero);
  165.  
  166.      ~FileName() {}
  167. };
  168.  
  169. //////////////////////////////////////////////////////////
  170. //                                                      //
  171. //                   Class FileSize                     //
  172. //                                                      //
  173. //       "Derived" from FileList which is con-          //
  174. //       structed prior to sorting the directory        //
  175. //       listing via File Size.  The default argu-      //
  176. //       ments are used if none are given.              //
  177. //                                                      //
  178. //////////////////////////////////////////////////////////
  179.  
  180. class FileSize : public FileList {
  181.  
  182. public:
  183.  
  184.      FileSize(const char* = "*.*", const int = zero);
  185.  
  186.      ~FileSize() {}
  187. };
  188.  
  189. //////////////////////////////////////////////////////////
  190. //                                                      //
  191. //                   Class FileDate                     //
  192. //                                                      //
  193. //       "Derived" from FileList which is con-          //
  194. //       structed prior to sorting the directory        //
  195. //       listing via File Dates.  The default argu-     //
  196. //       ments are used if none are given.              //
  197. //                                                      //
  198. //////////////////////////////////////////////////////////
  199.  
  200. class FileDate : public FileList {
  201.  
  202. public:
  203.  
  204.      FileDate(const char* = "*.*", const int = zero);
  205.  
  206.      ~FileDate() {}
  207. };
  208.  
  209. //////////////////////////////////////////////////////////
  210. //                                                      //
  211. //                   Class FileExt                      //
  212. //                                                      //
  213. //       "Derived" from FileList which is con-          //
  214. //       structed prior to sorting the directory        //
  215. //       listing via File Extensions.  The default      //
  216. //       arguments are used if none are given.          //
  217. //                                                      //
  218. //////////////////////////////////////////////////////////
  219.  
  220. class FileExt : public FileList {
  221.  
  222. public:
  223.  
  224.      FileExt(const char* = "*.*", const int = zero);
  225.  
  226.      ~FileExt() {}
  227. };
  228.  
  229.