| 708 | } |
| 709 | |
| 710 | Result<std::vector<WIN32_FIND_DATAW>> ListDirInternal(const PlatformFilename& dir_path) { |
| 711 | WIN32_FIND_DATAW find_data; |
| 712 | std::wstring pattern = PathWithoutTrailingSlash(dir_path) + L"\\*.*"; |
| 713 | HANDLE handle = FindFirstFileW(pattern.c_str(), &find_data); |
| 714 | if (handle == INVALID_HANDLE_VALUE) { |
| 715 | return IOErrorFromWinError(GetLastError(), "Cannot list directory '", |
| 716 | dir_path.ToString(), "'"); |
| 717 | } |
| 718 | |
| 719 | std::unique_ptr<HANDLE, decltype(&FindHandleDeleter)> handle_guard(&handle, |
| 720 | FindHandleDeleter); |
| 721 | |
| 722 | std::vector<WIN32_FIND_DATAW> results; |
| 723 | do { |
| 724 | // Skip "." and ".." |
| 725 | if (find_data.cFileName[0] == L'.') { |
| 726 | if (find_data.cFileName[1] == L'\0' || |
| 727 | (find_data.cFileName[1] == L'.' && find_data.cFileName[2] == L'\0')) { |
| 728 | continue; |
| 729 | } |
| 730 | } |
| 731 | results.push_back(find_data); |
| 732 | } while (FindNextFileW(handle, &find_data)); |
| 733 | |
| 734 | int errnum = GetLastError(); |
| 735 | if (errnum != ERROR_NO_MORE_FILES) { |
| 736 | return IOErrorFromWinError(GetLastError(), "Cannot list directory '", |
| 737 | dir_path.ToString(), "'"); |
| 738 | } |
| 739 | return results; |
| 740 | } |
| 741 | |
| 742 | Status FindOneFile(const PlatformFilename& fn, WIN32_FIND_DATAW* find_data, |
| 743 | bool* exists = nullptr) { |
nothing calls this directly
no test coverage detected