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.

206 lines
5.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  4. //
  5. // File: scopenm.hxx
  6. //
  7. // Contents: Scope enumerator for file systems
  8. //
  9. // History: 12-Dec-96 SitaramR Created
  10. //
  11. //--------------------------------------------------------------------------
  12. #pragma once
  13. #include <dirstk.hxx>
  14. #include <ciintf.h>
  15. #include <ffenum.hxx>
  16. #include <propret.hxx>
  17. #include <catalog.hxx>
  18. const DIRECTORY_QUOTA = 30; // Current directory's quota is 30%,
  19. // remaining 70% is for sub-directories
  20. const SHALLOW_DIR_LIMIT = 90; // For shallow scope enumeration,
  21. // RatioFinished goes upto 90% and
  22. // then stays put
  23. const FINDFIRST_BUFFER = 0x1000; // Size of buffer to retrieve in a
  24. // single call to FindFirst.
  25. //+-------------------------------------------------------------------------
  26. //
  27. // Class: CScopeEnum
  28. //
  29. // Purpose: Enumerator by scope for file stores
  30. //
  31. // History: 17-May-93 KyleP Created
  32. //
  33. // Notes: This class provides a true one-object-at-a-time enumerator
  34. // on top of the base NT scope enumerator.
  35. //
  36. //--------------------------------------------------------------------------
  37. class CScopeEnum : public CGenericPropRetriever, ICiCScopeEnumerator
  38. {
  39. public:
  40. //
  41. // From IUnknown
  42. //
  43. virtual SCODE STDMETHODCALLTYPE QueryInterface( REFIID riid, void **ppvObject );
  44. virtual ULONG STDMETHODCALLTYPE AddRef();
  45. virtual ULONG STDMETHODCALLTYPE Release();
  46. //
  47. // From CGenericPropRetriever
  48. //
  49. SCODE STDMETHODCALLTYPE BeginPropertyRetrieval( WORKID wid );
  50. SCODE STDMETHODCALLTYPE IsInScope( BOOL *pfInScope);
  51. //
  52. // From ICiCScopeEnumerator
  53. //
  54. SCODE STDMETHODCALLTYPE Begin();
  55. SCODE STDMETHODCALLTYPE CurrentDocument( WORKID *pWorkId);
  56. SCODE STDMETHODCALLTYPE NextDocument( WORKID *pWorkId );
  57. SCODE STDMETHODCALLTYPE RatioFinished( ULONG *pulDenominator,
  58. ULONG *pulNumerator);
  59. SCODE STDMETHODCALLTYPE End();
  60. //
  61. // Local methods
  62. //
  63. CScopeEnum( PCatalog & cat,
  64. ICiQueryPropertyMapper *pQueryPropMapper,
  65. CSecurityCache & secCache,
  66. BOOL fUsePathAlias,
  67. CRestriction const & scope );
  68. protected:
  69. virtual ~CScopeEnum();
  70. WORKID NextObject();
  71. //
  72. // Stat properties.
  73. //
  74. inline UNICODE_STRING const * GetName();
  75. inline UNICODE_STRING const * GetShortName();
  76. inline UNICODE_STRING const * GetPath();
  77. UNICODE_STRING const * GetVirtualPath();
  78. inline LONGLONG CreateTime();
  79. inline LONGLONG ModifyTime();
  80. inline LONGLONG AccessTime();
  81. inline LONGLONG ObjectSize();
  82. inline ULONG Attributes();
  83. private:
  84. void PushScope( CScopeRestriction const & scp );
  85. BOOL Refresh();
  86. HANDLE _hDir; // Handle to current directory
  87. CDirEntry const * _pCurEntry; // Position in buffer of current entry
  88. WORKID _widCurrent; // Wid on which the scope enumerator
  89. // is currently positioned
  90. XArray<BYTE> _xbBuf; // Buffer for results
  91. CDirStack _stack; // Stack of directories
  92. UNICODE_STRING _Name;
  93. UNICODE_STRING _ShortName;
  94. UNICODE_STRING _Path; // Path sans filename for items in
  95. // buffer.
  96. CRestriction const & _scope; // Scope to enumerate
  97. XPtr<CDirStackEntry> _xDirStackEntry; // Pointer to current directory entry
  98. int _iFirstSubDir; // Index to first sub-directory on stack
  99. ULONG _num; // Current value of numerator
  100. ULONG _numHighValue; // Numerator's high watermark for current dir
  101. ULONG _numLowValue; // Numerator's low watermark for current dir
  102. UNICODE_STRING _VPath; // Virtual path support
  103. // Limited to MAX_PATH, but so is IIS
  104. WCHAR _awcVPath[MAX_PATH]; // Virtual path support
  105. BOOL _fNullCatalog; // Are we dealing with a null catalog?
  106. };
  107. inline UNICODE_STRING const * CScopeEnum::GetName()
  108. {
  109. _Name.Length = _Name.MaximumLength = _pCurEntry->FilenameSize();
  110. //
  111. // We really need a UNICODE_STRING with a WCHAR const * Buffer.
  112. //
  113. _Name.Buffer = (WCHAR *)_pCurEntry->Filename();
  114. return( &_Name );
  115. }
  116. inline UNICODE_STRING const * CScopeEnum::GetShortName()
  117. {
  118. _ShortName.Length = _ShortName.MaximumLength = _pCurEntry->ShortNameSize();
  119. //
  120. // We really need a UNICODE_STRING with a WCHAR const * Buffer.
  121. //
  122. _ShortName.Buffer = (WCHAR *)_pCurEntry->ShortName();
  123. return( &_ShortName );
  124. }
  125. inline UNICODE_STRING const * CScopeEnum::GetPath()
  126. {
  127. return( &_Path );
  128. }
  129. inline LONGLONG CScopeEnum::CreateTime()
  130. {
  131. return( _pCurEntry->CreateTime() );
  132. }
  133. inline LONGLONG CScopeEnum::ModifyTime()
  134. {
  135. return( _pCurEntry->ModifyTime() );
  136. }
  137. inline LONGLONG CScopeEnum::AccessTime()
  138. {
  139. return( _pCurEntry->AccessTime() );
  140. }
  141. inline LONGLONG CScopeEnum::ObjectSize()
  142. {
  143. return( _pCurEntry->ObjectSize() );
  144. }
  145. inline ULONG CScopeEnum::Attributes()
  146. {
  147. return( _pCurEntry->Attributes() );
  148. }