Leaked source code of windows server 2003
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.

104 lines
2.5 KiB

  1. // DirWatch.h: interface for the CDirWatch class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_DIRWATCH_H__EC78FB5A_EF1C_11D0_A42F_00C04FB99B01__INCLUDED_)
  5. #define AFX_DIRWATCH_H__EC78FB5A_EF1C_11D0_A42F_00C04FB99B01__INCLUDED_
  6. #if _MSC_VER >= 1000
  7. #pragma once
  8. #endif // _MSC_VER >= 1000
  9. #include "OperationQueue.h"
  10. #define MAX_BUFFER 1024
  11. class CWatchFileSys; // forward reference
  12. class CWatchFileSys
  13. {
  14. public:
  15. // adding
  16. HRESULT Add(LPCTSTR szDir,LPCTSTR szPrj);
  17. // init/shutdown
  18. HRESULT NewInit(COpQueue *pOpQ);
  19. void ShutDown();
  20. // ctor/dtor
  21. CWatchFileSys();
  22. virtual ~CWatchFileSys();
  23. private:
  24. class CDirInfo
  25. {
  26. public:
  27. CDirInfo(LPCTSTR szDir,LPCTSTR szPrj)
  28. : m_hDir(NULL),m_iBuffer(MAX_BUFFER),m_pNext(NULL)
  29. {
  30. _ASSERTE(szDir && szPrj);
  31. m_szDir = szDir;
  32. m_szPrj = szPrj;
  33. memset(&m_Overlapped,0,sizeof(m_Overlapped));
  34. };
  35. ~CDirInfo()
  36. {
  37. if(m_hDir)
  38. CloseHandle(m_hDir);
  39. m_hDir = NULL;
  40. };
  41. HANDLE m_hDir;
  42. wstring m_szDir;
  43. wstring m_szPrj;
  44. CHAR m_cBuffer[MAX_BUFFER];
  45. DWORD m_iBuffer;
  46. OVERLAPPED m_Overlapped;
  47. CDirInfo *m_pNext;
  48. };
  49. class CWatchInfo
  50. {
  51. public:
  52. CWatchInfo(CWatchFileSys *pWatchFS)
  53. : m_pWatchFileSys(pWatchFS), m_hThread(NULL), m_iThreadID(0),
  54. m_hCompPort(NULL),m_pDirInfoHead(NULL),m_pDirInfoTail(NULL)
  55. {;};
  56. ~CWatchInfo()
  57. {
  58. CDirInfo *ptmp = NULL;
  59. while(m_pDirInfoHead)
  60. {
  61. ptmp = m_pDirInfoHead->m_pNext;
  62. delete m_pDirInfoHead;
  63. m_pDirInfoHead = ptmp;
  64. }
  65. m_pDirInfoTail = NULL;
  66. }
  67. void AddDirInfo(CDirInfo *pDirInfo)
  68. {
  69. if(m_pDirInfoTail == NULL)
  70. {
  71. _ASSERT(m_pDirInfoHead == NULL);
  72. m_pDirInfoHead = pDirInfo;
  73. m_pDirInfoTail = pDirInfo;
  74. } else {
  75. m_pDirInfoTail->m_pNext = pDirInfo;
  76. m_pDirInfoTail = pDirInfo;
  77. }
  78. }
  79. CWatchFileSys *m_pWatchFileSys;
  80. CDirInfo *m_pDirInfoHead;
  81. CDirInfo *m_pDirInfoTail;
  82. HANDLE m_hThread;
  83. DWORD m_iThreadID;
  84. HANDLE m_hCompPort;
  85. };
  86. static DWORD WINAPI NotificationThreadProc(LPVOID lpParam);
  87. BOOL IssueWatch(CDirInfo *pDirInfo);
  88. bool AddHelper(CWatchInfo &rWatchInfo,CDirInfo *pDirInfo);
  89. void ShutDownHelper(CWatchInfo &rWatchInfo);
  90. COpQueue *m_pOpQ;
  91. CWatchInfo m_WatchInfo;
  92. };
  93. #endif // !defined(AFX_DIRWATCH_H__EC78FB5A_EF1C_11D0_A42F_00C04FB99B01__INCLUDED_)