filesystem_glibc.diff

From: Samuel Thibault <samuel.thibault@gnu.org>
Subject: Fix build on GNU/Hurd
This commit is contained in:
su-fang 2023-04-25 16:04:00 +08:00
parent d5ac31c51a
commit 9ba44a419b
1 changed files with 7 additions and 0 deletions

View File

@ -4081,6 +4081,13 @@ GHC_INLINE path current_path(std::error_code& ec)
return path();
}
return path(std::wstring(buffer.get()), path::native_format);
#elif defined(__GLIBC__)
std::unique_ptr<char, decltype(&std::free)> buffer { ::getcwd(NULL, 0), std::free };
if (buffer == nullptr) {
ec = detail::make_system_error();
return path();
}
return path(buffer.get());
#else
size_t pathlen = static_cast<size_t>(std::max(int(::pathconf(".", _PC_PATH_MAX)), int(PATH_MAX)));
std::unique_ptr<char[]> buffer(new char[pathlen + 1]);