MCPcopy Create free account
hub / github.com/AGWA/git-crypt / get_directory_contents

Function get_directory_contents

util-win32.cpp:186–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186std::vector<std::string> get_directory_contents (const char* path)
187{
188 std::vector<std::string> filenames;
189 std::string patt(path);
190 if (!patt.empty() && patt[patt.size() - 1] != '/' && patt[patt.size() - 1] != '\\') {
191 patt.push_back('\\');
192 }
193 patt.push_back('*');
194
195 WIN32_FIND_DATAA ffd;
196 HANDLE h = FindFirstFileA(patt.c_str(), &ffd);
197 if (h == INVALID_HANDLE_VALUE) {
198 throw System_error("FindFirstFileA", patt, GetLastError());
199 }
200 do {
201 if (std::strcmp(ffd.cFileName, ".") != 0 && std::strcmp(ffd.cFileName, "..") != 0) {
202 filenames.push_back(ffd.cFileName);
203 }
204 } while (FindNextFileA(h, &ffd) != 0);
205
206 DWORD err = GetLastError();
207 if (err != ERROR_NO_MORE_FILES) {
208 throw System_error("FileNextFileA", patt, err);
209 }
210 FindClose(h);
211 return filenames;
212}

Callers

nothing calls this directly

Calls 1

System_errorClass · 0.85

Tested by

no test coverage detected