| 184 | } |
| 185 | |
| 186 | std::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 | } |
nothing calls this directly
no test coverage detected