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.

80 lines
2.7 KiB

  1. #ifndef FUSION_MIGRATION_FUSEIO_H
  2. #define FUSION_MIGRATION_FUSEIO_H
  3. #include "windows.h"
  4. class CDirWalk
  5. {
  6. public:
  7. enum ECallbackReason
  8. {
  9. eBeginDirectory = 1,
  10. eFile,
  11. eEndDirectory
  12. };
  13. CDirWalk();
  14. //
  15. // the callback cannot reenable what is has disabled
  16. // perhaps move these to be member data bools
  17. //
  18. enum ECallbackResult
  19. {
  20. eKeepWalking = 0x00000000,
  21. eError = 0x00000001,
  22. eSuccess = 0x00000002,
  23. eStopWalkingFiles = 0x00000004,
  24. eStopWalkingDirectories = 0x00000008,
  25. eStopWalkingDeep = 0x00000010
  26. };
  27. //
  28. // Just filter on like *.dll, in the future you can imagine
  29. // filtering on attributes like read onlyness, or running
  30. // SQL queries over the "File System Oledb Provider"...
  31. //
  32. // Also, note that we currently do a FindFirstFile/FindNextFile
  33. // loop for each filter, plus sometimes one more with *
  34. // to pick up directories. It is probably more efficient to
  35. // use * and then filter individually but I don't feel like
  36. // porting over \Vsee\Lib\Io\Wildcard.cpp right now (which
  37. // was itself ported from FsRtl, and should be in Win32!)
  38. //
  39. const PCWSTR* m_fileFiltersBegin;
  40. const PCWSTR* m_fileFiltersEnd;
  41. CStringBuffer m_strParent; // set this to the initial directory to walk
  42. SIZE_T m_cchOriginalPath;
  43. WIN32_FIND_DATAW m_fileData; // not valid for directory callbacks, but could be with a little work
  44. PVOID m_context;
  45. CStringBuffer m_strLastObjectFound;
  46. ECallbackResult
  47. (*m_callback)(
  48. ECallbackReason reason,
  49. CDirWalk* dirWalk
  50. );
  51. BOOL
  52. Walk();
  53. protected:
  54. ECallbackResult
  55. WalkHelper();
  56. private:
  57. CDirWalk(const CDirWalk &); // intentionally not implemented
  58. void operator =(const CDirWalk &); // intentionally not implemented
  59. };
  60. #define ENUM_BIT_OPERATIONS(e) \
  61. inline e operator|(e x, e y) { return static_cast<e>(static_cast<INT>(x) | static_cast<INT>(y)); } \
  62. inline e operator&(e x, e y) { return static_cast<e>(static_cast<INT>(x) & static_cast<INT>(y)); } \
  63. inline void operator&=(e& x, INT y) { x = static_cast<e>(static_cast<INT>(x) & y); } \
  64. inline void operator&=(e& x, e y) { x &= static_cast<INT>(y); } \
  65. inline void operator|=(e& x, INT y) { x = static_cast<e>(static_cast<INT>(x) | y); } \
  66. inline void operator|=(e& x, e y) { x |= static_cast<INT>(y); } \
  67. /* maybe more in the future */
  68. ENUM_BIT_OPERATIONS(CDirWalk::ECallbackResult)
  69. #endif