home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 8.img / CLASSEXM.ZIP / FILEDATA.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  6.0 KB  |  225 lines

  1. //
  2. // This file contains proprietary information of Borland International.
  3. // Copying or reproduction without prior written approval is prohibited.
  4. //
  5. // Copyright (c) 1990
  6. // Borland International
  7. // 1800 Scotts Valley Dr.
  8. // Scotts Valley, CA 95066
  9. // (408) 438-8400
  10. //
  11.  
  12. // Contents ----------------------------------------------------------------
  13. //
  14. //      FileData::FileData                            constructor
  15. //
  16. // Description
  17. //
  18. //     Class FileData member function implementation.
  19. //
  20. // End ---------------------------------------------------------------------
  21.  
  22. // Interface Dependencies ---------------------------------------------------
  23.  
  24. #ifndef __IOSTREAM_H
  25. #include <iostream.h>
  26. #define __IOSTREAM_H
  27. #endif
  28.  
  29. #ifndef __IOMANIP_H
  30. #include <iomanip.h>
  31. #define __IOMANIP_H
  32. #endif
  33.  
  34. #ifndef __DIR_H
  35. #include <dir.h>
  36. #define __DIR_H
  37. #endif
  38.  
  39. #ifndef __CSLTYPES_H
  40. #include <clstypes.h>
  41. #endif
  42.  
  43. #ifndef __FILEDATA_H
  44. #include "filedata.h"
  45. #endif
  46.  
  47. // End Interface Dependencies ------------------------------------------------
  48.  
  49. // Implementation Dependencies ----------------------------------------------
  50. // End Implementation Dependencies -------------------------------------------
  51.  
  52.  
  53. // Constructor //
  54.  
  55. FileData::FileData( ffblk& blk ) :
  56.     fileName( blk.ff_name ),
  57.     fileDate( (blk.ff_fdate >> 5) & 0x000F,
  58.               blk.ff_fdate & 0x0001F,
  59.               blk.ff_fdate >> 9 ),
  60.     fileSize( blk.ff_fsize ),
  61.     fileTime( blk.ff_ftime >> 11,
  62.               (blk.ff_ftime >> 5) & 0x3F,
  63.               blk.ff_ftime & 0x1F )
  64.  
  65. // Summary -----------------------------------------------------------------
  66. //
  67. //     Constructor for a file data object.  Constructs the file name
  68. //     file data, and file size objects.
  69. //
  70. // Parameters
  71. //
  72. //     blk
  73. //
  74. //     The DOS file block structure we are to use to construct the
  75. //     file data object.
  76. //
  77. // End ---------------------------------------------------------------------
  78. {
  79. }
  80. // End Constructor //
  81.  
  82.  
  83. // Member Function //
  84.  
  85. void FileData::printOn( ostream& outputStream ) const
  86.  
  87. // Summary -----------------------------------------------------------------
  88. //
  89. //     Displays the contents of a file data object on the given stream.
  90. //
  91. // Parameters
  92. //
  93. //     outputStream
  94. //
  95. //     The stream on which we are to display.
  96. //
  97. // End ---------------------------------------------------------------------
  98. {
  99.     outputStream << setw( 14 ) << setiosflags( ios::left )   << fileName
  100.                  << setw( 18 ) << fileDate
  101.                  << setw( 17 ) << resetiosflags( ios::left ) << fileTime
  102.                  << setw( 10 ) << fileSize << " bytes";
  103. }
  104. // End Member Function printOn //
  105.  
  106. // Member Function //
  107.  
  108. int FilesByName::isEqual( const Object& testFile ) const
  109.  
  110. // Summary -----------------------------------------------------------------
  111. //
  112. //      Determines whether two files are equal by comparing their names.
  113. //
  114. // Return Value
  115. //
  116. //      Returns 1 if the files have the same name, 0 otherwise.
  117. //
  118. // End ---------------------------------------------------------------------
  119. {
  120.     return fileName == ( (FilesByName&)testFile ).fileName;
  121. }
  122. // End Member Function FilesByName::isEqual //
  123.  
  124.  
  125. // Member Function //
  126.  
  127. int FilesByName::isLessThan( const Object& testFile ) const
  128.  
  129. // Summary -----------------------------------------------------------------
  130. //
  131. //      Determines the ordering of two files by comparing their names.
  132. //
  133. // Return Value
  134. //
  135. //      Returns 1 if this file is less than the given file, 0 otherwise.
  136. //
  137. // End ---------------------------------------------------------------------
  138. {
  139.     return fileName < ( (FilesByName&)testFile ).fileName;
  140. }
  141. // End Member Function FilesByName::isLessThan //
  142.  
  143.  
  144. // Member Function //
  145.  
  146. int FilesByDate::isEqual( const Object& testFile ) const
  147.  
  148. // Summary -----------------------------------------------------------------
  149. //
  150. //      Determines whether two files by are equal by comparing their dates.
  151. //
  152. // Return Value
  153. //
  154. //      Returns 1 if the files have the same date, 0 otherwise.
  155. //
  156. // End ---------------------------------------------------------------------
  157. {
  158.     return fileDate == ( (FilesByDate&)testFile ).fileDate &&
  159.            fileTime == ( (FilesByDate&)testFile ).fileTime;
  160. }
  161. // End Member Function FilesByDate::isEqual //
  162.  
  163.  
  164. // Member Function //
  165.  
  166. int FilesByDate::isLessThan( const Object& testFile ) const
  167.  
  168. // Summary -----------------------------------------------------------------
  169. //
  170. //      Determines the ordering of two files by comparing their names.
  171. //
  172. // Return Value
  173. //
  174. //      Returns 1 if this file is less than the given file, 0 otherwise.
  175. //
  176. // End ---------------------------------------------------------------------
  177. {
  178.     int res = fileDate < ( (FilesByDate&)testFile ).fileDate;
  179.     if( res != 0 )
  180.         return res;
  181.     else
  182.         return fileTime < ( (FilesByDate&)testFile ).fileTime;
  183. }
  184. // End Member Function FilesByDate::isLessThan //
  185.  
  186.  
  187. // Member Function //
  188.  
  189. int FilesBySize::isEqual( const Object& testFile ) const
  190.  
  191. // Summary -----------------------------------------------------------------
  192. //
  193. //      Determines the whether two files are equal by comparing their
  194. //      sizes.
  195. //
  196. // Return Value
  197. //
  198. //      Returns 1 if this file is less than the given file, 0 otherwise.
  199. //
  200. // End ---------------------------------------------------------------------
  201. {
  202.     return fileSize == ( (FilesBySize&)testFile ).fileSize;
  203. }
  204. // End Member Function FilesBySize::isEqual //
  205.  
  206.  
  207. // Member Function //
  208.  
  209. int FilesBySize::isLessThan( const Object& testFile ) const
  210.  
  211. // Summary -----------------------------------------------------------------
  212. //
  213. //      Determines the ordering of two files by comparing their sizes.
  214. //
  215. // Return Value
  216. //
  217. //      Returns 1 if this file is less than the given file, 0 otherwise.
  218. //
  219. // End ---------------------------------------------------------------------
  220. {
  221.     return fileSize < ( (FilesBySize&)testFile ).fileSize;
  222. }
  223. // End Member Function FilesBySize::isLessThan //
  224.  
  225.