From 9ba44a419b042937c55bafbab98766087d4f6839 Mon Sep 17 00:00:00 2001 From: su-fang Date: Tue, 25 Apr 2023 16:04:00 +0800 Subject: [PATCH] filesystem_glibc.diff From: Samuel Thibault Subject: Fix build on GNU/Hurd --- filesystem/filesystem.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/filesystem/filesystem.hpp b/filesystem/filesystem.hpp index fc8d987..5b6f8ce 100644 --- a/filesystem/filesystem.hpp +++ b/filesystem/filesystem.hpp @@ -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 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(std::max(int(::pathconf(".", _PC_PATH_MAX)), int(PATH_MAX))); std::unique_ptr buffer(new char[pathlen + 1]);