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.

154 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. fileenum.c
  5. Abstract:
  6. The code in this source file traverses a drive tree and calls
  7. an external callback function for each file. An INF can be
  8. provided to exclude files and/or directories from enumeration.
  9. Author:
  10. Jim Schmidt (jimschm) 16-Aug-1996
  11. Revision History:
  12. Marc R. Whitten (marcw) 11-Sep-1997 Tweaked exclusion handling code, removed
  13. obsolete code.
  14. Mike Condra (mikeco) 02-Jun-1996 Add fns to tap into file/path exclusion
  15. Jim Schmidt (jimschm) 20-Dec-1996 Added callback levels and made single
  16. source file for both A and W versions
  17. Jim Schmidt (jimschm) 27-Nov-1996 Added level and filter to EnumTree
  18. --*/
  19. #ifndef UNICODE
  20. #define UNICODE
  21. #endif
  22. #include "no_pch.h"
  23. #include "..\..\inc\fileenum.h"
  24. typedef struct {
  25. FILEENUMPROCW fnEnumCallback;
  26. FILEENUMFAILPROCW fnFailCallback;
  27. DWORD EnumID;
  28. LPVOID pParam;
  29. DWORD Levels;
  30. DWORD CurrentLevel;
  31. DWORD AttributeFilter;
  32. } ENUMSTRUCTW, *PENUMSTRUCTW;
  33. BOOL EnumTreeEngineW (LPCWSTR CurrentPath, PENUMSTRUCTW pes);
  34. BOOL IsPathExcludedW (DWORD EnumID, LPCWSTR Path);
  35. BOOL IsFileExcludedW (DWORD EnumID, LPCWSTR File, BYTE byBitmask[]);
  36. BOOL BuildExclusionsFromInfW (DWORD EnumID, PEXCLUDEINFW ExcludeInfStruct);
  37. void CreateBitmaskW (DWORD EnumID, LPCWSTR FindPattern, BYTE byBitmask[]);
  38. BOOL
  39. WINAPI
  40. FileEnum_Entry (
  41. IN HINSTANCE hinstDLL,
  42. IN DWORD dwReason,
  43. IN LPVOID lpv)
  44. /*++
  45. Routine Description:
  46. FileEnum_Entry is called after the C runtime is initialized, and its purpose
  47. is to initialize the globals for this process. For this LIB, it
  48. does nothing.
  49. Arguments:
  50. hinstDLL - (OS-supplied) Instance handle for the DLL
  51. dwReason - (OS-supplied) Type of initialization or termination
  52. lpv - (OS-supplied) Unused
  53. Return Value:
  54. TRUE because DLL always initializes properly.
  55. --*/
  56. {
  57. switch (dwReason)
  58. {
  59. case DLL_PROCESS_ATTACH:
  60. break;
  61. case DLL_PROCESS_DETACH:
  62. break;
  63. }
  64. return TRUE;
  65. }
  66. /*++
  67. Routine Description:
  68. GenerateEnumID maintains a static that is used to generate unique
  69. enumeration handles for callers. The enumeration handle is guaranteed to
  70. be unique for the first 2^32 calls.
  71. Arguments:
  72. none
  73. Return Value:
  74. A DWORD enumeration handle that may be used to identify an exclusion
  75. list.
  76. --*/
  77. DWORD
  78. GenerateEnumID (
  79. void
  80. )
  81. {
  82. static DWORD s_EnumID = 0;
  83. return ++s_EnumID;
  84. }
  85. //
  86. // Build W versions of fileenum APIs
  87. //
  88. #define FILEENUMPROCT FILEENUMPROCW
  89. #define FILEENUMFAILPROCT FILEENUMFAILPROCW
  90. #define PEXCLUDEINFT PEXCLUDEINFW
  91. #define ENUMSTRUCTT ENUMSTRUCTW
  92. #define PENUMSTRUCTT PENUMSTRUCTW
  93. #define EnumerateAllDrivesT EnumerateAllDrivesW
  94. #define EnumerateTreeT EnumerateTreeW
  95. #define EnumTreeEngineT EnumTreeEngineW
  96. #define IsPathExcludedT IsPathExcludedW
  97. #define CreateBitmaskT CreateBitmaskW
  98. #define IsFileExcludedT IsFileExcludedW
  99. #define BuildExclusionsFromInfT BuildExclusionsFromInfW
  100. #define ClearExclusionsT ClearExclusionsW
  101. #define ExcludeFileT ExcludeFileW
  102. #define ExcludePathT ExcludePathW
  103. #include "enumaw.c"