Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.3 KiB

  1. //
  2. // MODULE: FileTracker.h
  3. //
  4. // PURPOSE: Abstract classes in support of tracking file changes over time.
  5. // Interface for CFileToTrack, CFileTracker
  6. //
  7. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  8. //
  9. // AUTHOR: Joe Mabel
  10. //
  11. // ORIGINAL DATE: 9-15-98
  12. //
  13. // NOTES:
  14. //
  15. // Version Date By Comments
  16. //--------------------------------------------------------------------
  17. // V3.0 09-15-98 JM
  18. //
  19. #if !defined(AFX_FILETRACKER_H__3942A069_4CB5_11D2_95F6_00C04FC22ADD__INCLUDED_)
  20. #define AFX_FILETRACKER_H__3942A069_4CB5_11D2_95F6_00C04FC22ADD__INCLUDED_
  21. #if _MSC_VER >= 1000
  22. #pragma once
  23. #endif // _MSC_VER >= 1000
  24. #include "apgtsstr.h"
  25. #include <vector>
  26. using namespace std;
  27. // ideally, this would be a private class of CFileTracker, but that's incompatible with STL vector.
  28. class CFileToTrack
  29. {
  30. private:
  31. FILETIME m_ftLastWriteTime; // zeroed to indicate not yet read; otherwise, file time
  32. // when last checked
  33. CString m_strPathName; // full pathname of file to monitor
  34. bool m_bFileExists; // when we last checked for the file, did it exist
  35. public:
  36. CFileToTrack(); // do not instantiate; exists only so vector can compile
  37. // The only constructor you should call is:
  38. CFileToTrack(const CString & strPathName);
  39. virtual ~CFileToTrack();
  40. void CheckFile(bool & bFileExists, bool & bTimeChanged, const bool bLogIfMissing= true );
  41. // to keep vector happy
  42. bool operator < (const CFileToTrack & x) const {return this->m_strPathName < x.m_strPathName ;};
  43. bool operator == (const CFileToTrack & x) const {return this->m_strPathName == x.m_strPathName ;};
  44. };
  45. // abstract class. Intended as base class for distinct classes tracking LST files, DSC/BES/HTI files
  46. // These must provide there own overrides of TakeAction.
  47. class CFileTracker
  48. {
  49. private:
  50. vector<CFileToTrack> m_arrFile;
  51. public:
  52. CFileTracker();
  53. virtual ~CFileTracker();
  54. void AddFile(const CString & strPathName);
  55. bool Changed( const bool bLogIfMissing= true );
  56. // to keep vector happy. Note that no two CFileTracker's will ever test equal
  57. // even if their content is identical.
  58. bool operator < (const CFileTracker & x) const {return this < &x;};
  59. bool operator == (const CFileTracker & x) const {return this == &x;};
  60. };
  61. #endif // !defined(AFX_FILETRACKER_H__3942A069_4CB5_11D2_95F6_00C04FC22ADD__INCLUDED_)