MCPcopy Create free account
hub / github.com/apache/arrow / ListDirInternal

Function ListDirInternal

cpp/src/arrow/util/io_util.cc:710–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

708}
709
710Result<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
742Status FindOneFile(const PlatformFilename& fn, WIN32_FIND_DATAW* find_data,
743 bool* exists = nullptr) {

Callers

nothing calls this directly

Calls 4

PathWithoutTrailingSlashFunction · 0.85
IOErrorFromWinErrorFunction · 0.85
push_backMethod · 0.80
ToStringMethod · 0.45

Tested by

no test coverage detected