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.

209 lines
5.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: scaninfo.hxx
  7. //
  8. // Contents: Scan scope info
  9. //
  10. // History: 1-23-96 srikants Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. //+---------------------------------------------------------------------------
  15. //
  16. // Class: CCiScanInfo
  17. //
  18. // Purpose: A class to hold information for a single scope that must be
  19. // scanned. The class is used for regular scans and for scans on
  20. // usn enabled scopes.
  21. //
  22. // History: 1-19-96 srikants Created
  23. // 7-May-97 SitaramR Usns
  24. //
  25. //----------------------------------------------------------------------------
  26. class CCiScanInfo : public CDoubleLink
  27. {
  28. enum EState { eStart, eRetry, eDone };
  29. enum EWorkType { eNone, eScan, eDelete, eRename, eMonitor, eFullUsnScan };
  30. public:
  31. enum { MAX_RETRIES = 8 };
  32. CCiScanInfo( XArray<WCHAR> & xPath,
  33. PARTITIONID partId,
  34. ULONG updFlag,
  35. BOOL fDoDeletions,
  36. VOLUMEID volumeId,
  37. USN usnStart,
  38. BOOL fUserInitiated = FALSE,
  39. BOOL fNewScope = FALSE )
  40. : _state(eStart),
  41. _op(eNone),
  42. _pwcsRoot(xPath.Acquire()),
  43. _pwcsDirOldName(0),
  44. _fProcessRoot(FALSE),
  45. _partId(partId),
  46. _updFlag(updFlag),
  47. _nRetries(0),
  48. _fDoDeletions(fDoDeletions),
  49. _volumeId(volumeId),
  50. _usnStart(usnStart),
  51. _fUserInitiated( fUserInitiated ),
  52. _fNewScope( fNewScope )
  53. {
  54. }
  55. ~CCiScanInfo()
  56. {
  57. delete [] _pwcsRoot;
  58. delete [] _pwcsDirOldName;
  59. }
  60. WCHAR const * GetPath() const { return _pwcsRoot; }
  61. WCHAR * GetPath() { return _pwcsRoot; }
  62. WCHAR * GetDirOldName() { return _pwcsDirOldName; }
  63. void CCiScanInfo::LokSetPath( WCHAR const *pwcsPath )
  64. {
  65. ULONG ulLen = wcslen( pwcsPath );
  66. if ( ulLen > wcslen( _pwcsRoot ) )
  67. {
  68. delete [] _pwcsRoot;
  69. _pwcsRoot = 0;
  70. _pwcsRoot = new WCHAR[ulLen + 1];
  71. }
  72. RtlCopyMemory( _pwcsRoot, pwcsPath, (ulLen+1) * sizeof( WCHAR ) );
  73. }
  74. void CCiScanInfo::SetDirOldName( const WCHAR * pwcsDirOldName )
  75. {
  76. ULONG ulLen = wcslen( pwcsDirOldName );
  77. _pwcsDirOldName = new WCHAR[ulLen + 1];
  78. RtlCopyMemory( _pwcsDirOldName, pwcsDirOldName, ( ulLen + 1 )*sizeof( WCHAR ) );
  79. }
  80. BOOL GetProcessRoot() { return _fProcessRoot; }
  81. void SetProcessRoot() { _fProcessRoot = TRUE; }
  82. PARTITIONID PartitionId() const { return _partId; }
  83. ULONG GetFlags() const { return _updFlag; }
  84. void SetDoDeletions() { _fDoDeletions = TRUE; }
  85. BOOL IsDoDeletions() const { return _fDoDeletions; }
  86. unsigned GetRetries() const { return _nRetries; }
  87. void IncrementRetries() { _nRetries++; }
  88. BOOL IsRetryableError( NTSTATUS status ) const
  89. {
  90. return STATUS_INSUFFICIENT_RESOURCES == status ||
  91. STATUS_DISK_FULL == status ||
  92. ERROR_DISK_FULL == status ||
  93. HRESULT_FROM_WIN32(ERROR_DISK_FULL) == status ||
  94. FILTER_S_DISK_FULL == status ||
  95. CI_E_CONFIG_DISK_FULL == status;
  96. }
  97. void SetStartState()
  98. {
  99. _state = eStart;
  100. _op = eNone;
  101. }
  102. BOOL LokIsInFinalState() const
  103. {
  104. return eDone == _state;
  105. }
  106. void SetScan()
  107. {
  108. Win4Assert( !LokIsInFinalState() );
  109. _op = eScan;
  110. }
  111. BOOL LokIsInScan() const { return eScan == _op; }
  112. void LokSetRetry()
  113. {
  114. if ( !LokIsInFinalState() )
  115. {
  116. _nRetries++;
  117. _state = eRetry;
  118. }
  119. }
  120. BOOL LokIsRetry() const { return eRetry == _state; }
  121. void LokSetDone()
  122. {
  123. Win4Assert( LokIsInScan() || LokIsInFullUsnScan() || LokIsDelScope() || LokIsRenameDir() || LokIsMonitorOnly() );
  124. _state = eDone;
  125. }
  126. BOOL LokIsDone() const
  127. {
  128. return eDone == _state;
  129. }
  130. void LokSetDelScope()
  131. {
  132. Win4Assert( eNone == _op || eScan == _op || eRename == _op || eMonitor == _op );
  133. _op = eDelete;
  134. }
  135. BOOL LokIsDelScope() const { return eDelete == _op; }
  136. void SetFullUsnScan()
  137. {
  138. _op = eFullUsnScan;
  139. }
  140. BOOL LokIsInFullUsnScan() const { return eFullUsnScan == _op; }
  141. void SetRenameDir() { _op = eRename; }
  142. BOOL LokIsRenameDir() const { return _op == eRename; }
  143. void SetMonitorOnly() { _op = eMonitor; }
  144. BOOL LokIsMonitorOnly() const { return _op == eMonitor; }
  145. EWorkType LokGetWorkType() const { return _op; }
  146. VOLUMEID VolumeId() { return _volumeId; }
  147. USN UsnStart() { return _usnStart; }
  148. void SetStartUsn(USN usn) { _usnStart = usn; }
  149. BOOL IsUserInitiated() const { return _fUserInitiated; }
  150. BOOL IsNewScope() const { return _fNewScope; }
  151. private:
  152. EState _state; // state of the operation
  153. EWorkType _op; // Operation being performed
  154. WCHAR * _pwcsRoot;
  155. WCHAR * _pwcsDirOldName;// Previous name of dir (during dir rename)
  156. BOOL _fProcessRoot; // Should the root dir also be filtered ?
  157. PARTITIONID _partId;
  158. ULONG _updFlag;
  159. BOOL _fDoDeletions;
  160. unsigned _nRetries;
  161. VOLUMEID _volumeId; // Volume id
  162. USN _usnStart; // Usn to start monitoriing from
  163. BOOL _fUserInitiated; // Did the user force a scan?
  164. BOOL _fNewScope; // TRUE if a new scope
  165. };
  166. typedef class TDoubleList<CCiScanInfo> CScanInfoList;
  167. typedef class TFwdListIter<CCiScanInfo, CScanInfoList> CFwdScanInfoIter;