filetime.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 2k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #ifndef _INC_CSCVIEW_FILETIME_H
  2. #define _INC_CSCVIEW_FILETIME_H
  3. #ifndef _WINDOWS_
  4. #   include <windows.h>
  5. #endif
  6. #ifndef _INC_CSCVIEW_STRCLASS_H
  7. #   include "strclass.h"
  8. #endif
  9. //
  10. // Trivial class to represent a file-time value.
  11. // Allows comparison of file times using standard == and != operators.
  12. //
  13. class FileTime
  14. {
  15.     public:
  16.         explicit FileTime(const FILETIME& ft)
  17.             { FileTimeToLocalFileTime(&ft, &m_time); }
  18.         explicit FileTime(const WIN32_FIND_DATA& fd)
  19.             { FileTimeToLocalFileTime(&fd.ftLastWriteTime, &m_time); }
  20.         FileTime(void)
  21.             { m_time.dwLowDateTime = m_time.dwHighDateTime = 0; }
  22.         operator FILETIME() const
  23.             { return m_time; }
  24.         int Compare(const FileTime& rhs) const
  25.             { return CompareFileTime(&m_time, &rhs.m_time); }
  26.         FILETIME GetTime(void) const
  27.             { return m_time; }
  28.         void GetString(CString *pstr) const;
  29.     private:
  30.         FILETIME m_time;
  31.         //
  32.         // Default bitwise copy semantics are OK.
  33.         //
  34.         friend bool operator == (const FileTime& a, const FileTime& b);
  35.         friend bool operator != (const FileTime& a, const FileTime& b);
  36.         friend bool operator <  (const FileTime& a, const FileTime& b);
  37.         friend bool operator >  (const FileTime& a, const FileTime& b);
  38.         friend bool operator <= (const FileTime& a, const FileTime& b);
  39.         friend bool operator >= (const FileTime& a, const FileTime& b);
  40. };
  41. //
  42. // The various comparison operators for FileTime objects.
  43. //
  44. inline bool operator == (const FileTime& a, const FileTime& b)
  45. {
  46.     return 0 == a.Compare(b);
  47. }
  48. inline bool operator != (const FileTime& a, const FileTime& b)
  49. {
  50.     return !(a == b);
  51. }
  52. inline bool operator < (const FileTime& a, const FileTime& b)
  53. {
  54.     return 0 > a.Compare(b);
  55. }
  56. inline bool operator <= (const FileTime& a, const FileTime& b)
  57. {
  58.     return (a < b) || (a == b);
  59. }
  60. inline bool operator > (const FileTime& a, const FileTime& b)
  61. {
  62.     return !(a < b) && !(a == b);
  63. }
  64. inline bool operator >= (const FileTime& a, const FileTime& b)
  65. {
  66.     return (a > b) || (a == b);
  67. }
  68. #endif //_INC_CSCVIEW_FILETIME_H