-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFileEnumerator.cpp
More file actions
39 lines (36 loc) · 1.19 KB
/
Copy pathFileEnumerator.cpp
File metadata and controls
39 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "common.h"
#include "FileEnumerator.h"
void eoraptor::FileEnumerator::EnumerateFilesAtPath(const std::wstring& path, const eoraptor::FileEnumeratorCallback& callback)
{
WIN32_FIND_DATA findData = {};
unique_handle findHandle(FindFirstFile((path + L"\\*").c_str(), &findData), FindClose);
if (findHandle.get() == INVALID_HANDLE_VALUE)
{
throw std::system_error(std::error_code(GetLastError(), std::system_category()));
}
do
{
auto fileName = std::wstring(findData.cFileName);
if ((fileName != L".") && (fileName != L".."))
{
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
{
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
eoraptor::FileEnumerator::EnumerateFilesAtPath(path + L"\\" + findData.cFileName, callback);
}
else
{
if ((fileName.find(L".dll") != std::wstring::npos) ||
(fileName.find(L".exe") != std::wstring::npos) ||
(fileName.find(L".mui") != std::wstring::npos))
{
wchar_t combinedPath[MAX_PATH] = {};
PathCombine(combinedPath, path.c_str(), findData.cFileName);
callback(std::wstring(combinedPath));
}
}
}
}
} while (FindNextFile(findHandle.get(), &findData));
}