| 91 | } |
| 92 | |
| 93 | List<std::pair<String, bool>> File::dirList(const String& dirName, bool skipDots) { |
| 94 | List<std::pair<String, bool>> fileList; |
| 95 | WIN32_FIND_DATAW findFileData; |
| 96 | HANDLE hFind; |
| 97 | |
| 98 | hFind = FindFirstFileW(stringToUtf16(File::relativeTo(dirName, "*")).get(), &findFileData); |
| 99 | if (hFind == INVALID_HANDLE_VALUE) |
| 100 | throw IOException(strf("Invalid file handle in dirList of '{}', error is %u", dirName, GetLastError())); |
| 101 | |
| 102 | while (true) { |
| 103 | String entry = utf16ToString(findFileData.cFileName); |
| 104 | if (!skipDots || (entry != "." && entry != "..")) |
| 105 | fileList.append({entry, (FILE_ATTRIBUTE_DIRECTORY & findFileData.dwFileAttributes) != 0}); |
| 106 | if (!FindNextFileW(hFind, &findFileData)) |
| 107 | break; |
| 108 | } |
| 109 | |
| 110 | DWORD dwError = GetLastError(); |
| 111 | FindClose(hFind); |
| 112 | |
| 113 | if ((dwError != ERROR_NO_MORE_FILES) && (dwError != NO_ERROR)) |
| 114 | throw IOException(strf("FindNextFile error in dirList of '{}'. Error is %u", dirName, dwError)); |
| 115 | |
| 116 | return fileList; |
| 117 | } |
| 118 | |
| 119 | String File::baseName(const String& fileName) { |
| 120 | return String(fileName).rextract("\\/"); |
nothing calls this directly
no test coverage detected