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.

194 lines
5.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: purge.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef __CSCUI_PURGE_H
  11. #define __CSCUI_PURGE_H
  12. //
  13. // Definitions for the dwFlags bits in PurgeCache().
  14. //
  15. #define PURGE_FLAG_NONE 0x00000000
  16. #define PURGE_FLAG_PINNED 0x00000001
  17. #define PURGE_FLAG_UNPINNED 0x00000002
  18. #define PURGE_FLAG_ALL 0x00000003
  19. #define PURGE_IGNORE_ACCESS 0x80000000
  20. //
  21. // Phase identification constants specified in dwPhase argument to PurgeCache
  22. // and returned in PURGECALLBACKINFO.dwPhase.
  23. //
  24. #define PURGE_PHASE_SCAN 0
  25. #define PURGE_PHASE_DELETE 1
  26. class CCachePurger; // fwd decl.
  27. //
  28. // Purge callback function pointer type.
  29. //
  30. typedef BOOL (CALLBACK * LPFNPURGECALLBACK)(CCachePurger *pPurger);
  31. class CCachePurgerSel
  32. {
  33. public:
  34. CCachePurgerSel(void)
  35. : m_dwFlags(0),
  36. m_hdpaShares(DPA_Create(8)),
  37. m_psidUser(NULL) { };
  38. ~CCachePurgerSel(void);
  39. DWORD Flags(void) const
  40. { return m_dwFlags; }
  41. BOOL SetUserSid(PSID psid);
  42. PSID UserSid(void) const
  43. { return m_psidUser; }
  44. int ShareCount(void) const
  45. { return m_hdpaShares ? DPA_GetPtrCount(m_hdpaShares) : 0; }
  46. LPCTSTR ShareName(int iShare) const
  47. { return m_hdpaShares ? (LPCTSTR)DPA_GetPtr(m_hdpaShares, iShare) : NULL; }
  48. DWORD SetFlags(DWORD dwFlags)
  49. { m_dwFlags = dwFlags; return m_dwFlags; }
  50. DWORD AddFlags(DWORD dwFlags)
  51. { m_dwFlags |= dwFlags; return m_dwFlags; }
  52. BOOL AddShareName(LPCTSTR pszShare);
  53. private:
  54. DWORD m_dwFlags;
  55. HDPA m_hdpaShares;
  56. PSID m_psidUser;
  57. LPTSTR MyStrDup(LPCTSTR psz);
  58. //
  59. // Prevent copy.
  60. //
  61. CCachePurgerSel(const CCachePurgerSel& rhs);
  62. CCachePurgerSel& operator = (const CCachePurgerSel& rhs);
  63. };
  64. class CCachePurger
  65. {
  66. public:
  67. CCachePurger(const CCachePurgerSel& desc,
  68. LPFNPURGECALLBACK pfnCbk,
  69. LPVOID pvCbkData);
  70. ~CCachePurger(void);
  71. HRESULT Scan(void)
  72. { return Process(PURGE_PHASE_SCAN); }
  73. HRESULT Delete(void)
  74. { return Process(PURGE_PHASE_DELETE); }
  75. static void AskUserWhatToPurge(HWND hwndParent, CCachePurgerSel *pDesc);
  76. ULONGLONG BytesToScan(void) const
  77. { return m_ullBytesToScan; }
  78. ULONGLONG BytesScanned(void) const
  79. { return m_ullBytesScanned; }
  80. ULONGLONG BytesToDelete(void) const
  81. { return m_ullBytesToDelete; }
  82. ULONGLONG BytesDeleted(void) const
  83. { return m_ullBytesDeleted; }
  84. ULONGLONG FileBytes(void) const
  85. { return m_ullFileBytes; }
  86. DWORD Phase(void) const
  87. { return m_dwPhase; }
  88. DWORD FilesToScan(void) const
  89. { return m_cFilesToScan; }
  90. DWORD FilesToDelete(void) const
  91. { return m_cFilesToDelete; }
  92. DWORD FilesScanned(void) const
  93. { return m_cFilesScanned; }
  94. DWORD FilesDeleted(void) const
  95. { return m_cFilesDeleted; }
  96. DWORD FileOrdinal(void) const
  97. { return m_iFile; }
  98. DWORD FileAttributes(void) const
  99. { return m_dwFileAttributes; }
  100. DWORD FileDeleteResult(void) const
  101. { return m_dwResult; }
  102. LPCTSTR FileName(void) const
  103. { return m_pszFile; }
  104. LPVOID CallbackData(void) const
  105. { return m_pvCbkData; }
  106. BOOL WillDeleteThisFile(void) const
  107. { return m_bWillDelete; }
  108. private:
  109. //
  110. // State information to support callback info query functions.
  111. //
  112. ULONGLONG m_ullBytesToScan; // Total bytes to scan.
  113. ULONGLONG m_ullBytesToDelete; // Total bytes to delete. Known after scanning.
  114. ULONGLONG m_ullBytesScanned; // Total bytes scanned.
  115. ULONGLONG m_ullBytesDeleted; // Total bytes deleted.
  116. ULONGLONG m_ullFileBytes; // Size of this file in bytes.
  117. DWORD m_dwPhase; // PURGE_PHASE_XXXXXX value.
  118. DWORD m_cFilesToScan; // Total files to be scanned.
  119. DWORD m_cFilesScanned; // Total files actually scanned.
  120. DWORD m_cFilesToDelete; // Total files to delete. Known after scanning.
  121. DWORD m_cFilesDeleted; // Total files actually deleted.
  122. DWORD m_iFile; // "This" file's number [0..(n-1)].
  123. DWORD m_dwFileAttributes; // This file's Win32 file attributes.
  124. DWORD m_dwResult; // Win32 result code from CSCDelete()
  125. HANDLE m_hmutexPurgeInProg;// Purge-in-progress mutex.
  126. LPCTSTR m_pszFile; // This file's full path.
  127. LPVOID m_pvCbkData; // App data provided in DeleteCacheFiles().
  128. BOOL m_bWillDelete; // 1 == File will be deleted in delete phase.
  129. DWORD m_dwFlags; // PURGE_FLAG_XXXXX flags.
  130. LPFNPURGECALLBACK m_pfnCbk; // Ptr to callback function.
  131. const CCachePurgerSel& m_sel; // Ref to selection info.
  132. bool m_bIsValid; // Ctor success indicator.
  133. bool m_bDelPinned; // Do dwFlags say delete "pinned"?
  134. bool m_bDelUnpinned;// Do dwFlags say delete "non-pinned"?
  135. bool m_bUserIsAnAdmin;
  136. bool m_bIgnoreAccess;
  137. HRESULT Process(DWORD dwPhase);
  138. bool ProcessDirectory(LPTSTR pszPath, DWORD dwPhase, bool bShareIsOffline);
  139. //
  140. // Prevent copy.
  141. //
  142. CCachePurger(const CCachePurger& rhs);
  143. CCachePurger& operator = (const CCachePurger& rhs);
  144. };
  145. #endif __CSCUI_PURGE_H