MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / list_files

Function list_files

src/spellers/HunspellInterface.cpp:81–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79} // namespace
80
81static 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
121template <typename OutputCharType, typename InputCharType>
122static std::basic_string<OutputCharType> convert_impl(const IconvWrapperT &conv, std::basic_string_view<InputCharType> input) {

Callers 2

set_directoryMethod · 0.85

Calls 2

c_strMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected