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.

117 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. Enumdir.h
  5. Abstract:
  6. Class definition for the directory
  7. enumeration class.
  8. Notes:
  9. Unicode only right now.
  10. History:
  11. 02/21/2001 rparsons Created
  12. --*/
  13. #include <windows.h>
  14. #include <windowsx.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <errno.h>
  18. #include <ctype.h>
  19. #include <string.h>
  20. #include <io.h>
  21. #include <fcntl.h>
  22. #include <malloc.h>
  23. #include <sys\types.h>
  24. #include <sys\stat.h>
  25. //
  26. // Determine if an argument is present by testing a value of NULL
  27. //
  28. #define ARGUMENT_IS_PRESENT( ArgumentPointer ) (\
  29. (LPSTR)(ArgumentPointer) != (LPSTR)(NULL) )
  30. //
  31. // Useful rounding macros that the rounding amount is always a
  32. // power of two.
  33. //
  34. #define ROUND_DOWN( Size, Amount ) ((DWORD)(Size) & ~((Amount) - 1))
  35. #define ROUND_UP( Size, Amount ) (((DWORD)(Size) + ((Amount) - 1)) & ~((Amount) - 1))
  36. //
  37. // Directory enumeration and file notification definitions.
  38. //
  39. typedef
  40. BOOL (*PDIRECTORY_ENUMERATE_ROUTINE)(
  41. LPCWSTR lpwPath,
  42. PWIN32_FIND_DATA pFindFileData,
  43. PVOID pEnumerateParameter
  44. );
  45. //
  46. // Data structures private to the EnumerateDirectoryTree function.
  47. //
  48. typedef struct _ENUMERATE_DIRECTORY_STACK {
  49. LPWSTR PathEnd;
  50. HANDLE FindHandle;
  51. } ENUMERATE_DIRECTORY_STACK, *PENUMERATE_DIRECTORY_STACK;
  52. #define MAX_DEPTH 256
  53. typedef struct _ENUMERATE_DIRECTORY_STATE {
  54. DWORD Depth;
  55. ENUMERATE_DIRECTORY_STACK Stack[ MAX_DEPTH ];
  56. WCHAR Path[ MAX_PATH ];
  57. } ENUMERATE_DIRECTORY_STATE, *PENUMERATE_DIRECTORY_STATE;
  58. //
  59. // Virtual Buffer data structure
  60. //
  61. typedef struct _VIRTUAL_BUFFER {
  62. LPVOID Base;
  63. ULONG PageSize;
  64. LPVOID CommitLimit;
  65. LPVOID ReserveLimit;
  66. } VIRTUAL_BUFFER, *PVIRTUAL_BUFFER;
  67. class CEnumDir {
  68. public:
  69. BOOL EnumerateDirectoryTree(IN LPCWSTR DirectoryPath,
  70. IN PDIRECTORY_ENUMERATE_ROUTINE EnumerateRoutine,
  71. IN BOOL fEnumSubDirs,
  72. IN PVOID EnumerateParameter);
  73. private:
  74. BOOL CreateVirtualBuffer(OUT PVIRTUAL_BUFFER Buffer,
  75. IN DWORD CommitSize,
  76. IN DWORD ReserveSize OPTIONAL);
  77. BOOL ExtendVirtualBuffer(IN PVIRTUAL_BUFFER Buffer,
  78. IN LPVOID Address);
  79. BOOL TrimVirtualBuffer(IN PVIRTUAL_BUFFER Buffer);
  80. BOOL FreeVirtualBuffer(IN PVIRTUAL_BUFFER Buffer);
  81. int VirtualBufferExceptionFilter(IN DWORD ExceptionCode,
  82. IN PEXCEPTION_POINTERS ExceptionInfo,
  83. IN OUT PVIRTUAL_BUFFER Buffer);
  84. };