| 79 | } // namespace |
| 80 | |
| 81 | static std::vector<std::wstring> list_files(const wchar_t *path, const wchar_t *mask, const wchar_t *filter) { |
| 82 | WIN32_FIND_DATA ffd; |
| 83 | std::stack<std::wstring> directories; |
| 84 | |
| 85 | directories.push(path); |
| 86 | std::vector<std::wstring> out; |
| 87 | |
| 88 | while (!directories.empty()) { |
| 89 | auto top = std::move(directories.top()); |
| 90 | auto spec = top + L"\\"s + mask; |
| 91 | directories.pop(); |
| 92 | |
| 93 | HANDLE h_find = FindFirstFile(spec.c_str(), &ffd); |
| 94 | if (h_find == INVALID_HANDLE_VALUE) { |
| 95 | return {}; |
| 96 | } |
| 97 | |
| 98 | do { |
| 99 | if (ffd.cFileName != L"."sv && ffd.cFileName != L".."sv) { |
| 100 | auto buf = top + L"\\" + ffd.cFileName; |
| 101 | if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { |
| 102 | directories.push(buf); |
| 103 | } else { |
| 104 | if (PathMatchSpec(buf.c_str(), filter)) |
| 105 | out.push_back(buf); |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | while (FindNextFile(h_find, &ffd) != 0); |
| 110 | |
| 111 | if (GetLastError() != ERROR_NO_MORE_FILES) { |
| 112 | FindClose(h_find); |
| 113 | return {}; |
| 114 | } |
| 115 | |
| 116 | FindClose(h_find); |
| 117 | } |
| 118 | return out; |
| 119 | } |
| 120 | |
| 121 | template <typename OutputCharType, typename InputCharType> |
| 122 | static std::basic_string<OutputCharType> convert_impl(const IconvWrapperT &conv, std::basic_string_view<InputCharType> input) { |
no test coverage detected