home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / TESTDIR.PAK / FILEDATA.CPP next >
C/C++ Source or Header  |  1995-08-29  |  2KB  |  80 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  FILEDATA.CPP                                                          */
  4. /*                                                                        */
  5. /*  Copyright (c) 1991, 1993 Borland International                        */
  6. /*  All Rights Reserved.                                                  */
  7. /*                                                                        */
  8. /*  Sorted container example source file                                  */
  9. /*                                                                        */
  10. /*------------------------------------------------------------------------*/
  11.  
  12. #ifndef __IOSTREAM_H
  13. #include <iostream.h>
  14. #endif
  15.  
  16. #ifndef __IOMANIP_H
  17. #include <iomanip.h>
  18. #endif
  19.  
  20. #ifndef __DIR_H
  21. #include <dir.h>
  22. #define __DIR_H
  23. #endif
  24.  
  25. #ifndef __FILEDATA_H
  26. #include "filedata.h"
  27. #endif
  28.  
  29. FileData::FileData( ffblk& blk ) :
  30.     FileName( blk.ff_name ),
  31.     FileSize( blk.ff_fsize ),
  32.     FileTime( 
  33.               TDate( 
  34.                      blk.ff_fdate & 0x0001F,
  35.                      (blk.ff_fdate >> 5) & 0x000F,
  36.                      (blk.ff_fdate >> 9) + 80 ),
  37.               blk.ff_ftime >> 11,
  38.               (blk.ff_ftime >> 5) & 0x3F,
  39.               blk.ff_ftime & 0x1F )
  40. {
  41. }
  42.  
  43. ostream& operator << ( ostream&os, const FileData& f )
  44. {
  45.     os << setw( 14 ) << setiosflags( ios::left )   << f.FileName
  46.        << setw( 27 ) << f.FileTime << resetiosflags( ios::left )
  47.        << setw( 10 ) << f.FileSize << " bytes";
  48.     return os;
  49. }
  50.  
  51. int FilesByName::operator == ( const FilesByName& testFile ) const
  52. {
  53.     return FileName == testFile.FileName;
  54. }
  55.  
  56. int FilesByName::operator <  ( const FilesByName& testFile ) const
  57. {
  58.     return FileName < testFile.FileName;
  59. }
  60.  
  61. int FilesByDate::operator == ( const FilesByDate& testFile ) const
  62. {
  63.     return FileTime == testFile.FileTime;
  64. }
  65.  
  66. int FilesByDate::operator <  ( const FilesByDate& testFile ) const
  67. {
  68.     return FileTime < testFile.FileTime;
  69. }
  70.  
  71. int FilesBySize::operator == ( const FilesBySize& testFile ) const
  72. {
  73.     return FileSize == testFile.FileSize;
  74. }
  75.  
  76. int FilesBySize::operator <  ( const FilesBySize& testFile ) const
  77. {
  78.     return FileSize < testFile.FileSize;
  79. }
  80.