From ab8a78d806f2a703680a57d782a65c3a8f892fb6 Mon Sep 17 00:00:00 2001 From: actboy168 Date: Fri, 8 Apr 2022 11:18:01 +0800 Subject: [PATCH 1/2] copy_file also copies permissions --- include/ghc/filesystem.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 9540b44..2d96915 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -3956,6 +3956,14 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options ::close(in); return false; } + if (st.permissions() != sf.permissions()) { + if (::fchmod(out, static_cast(sf.permissions() & perms::all)) != 0) { + ec = detail::make_system_error(); + ::close(in); + ::close(out); + return false; + } + } ssize_t br, bw; while ((br = ::read(in, buffer.data(), buffer.size())) > 0) { ssize_t offset = 0; From 28f7c929e07e0f0ada2332810ab38b68cb1e5342 Mon Sep 17 00:00:00 2001 From: actboy168 Date: Fri, 8 Apr 2022 11:43:15 +0800 Subject: [PATCH 2/2] fixes --- include/ghc/filesystem.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 2d96915..8632e91 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -3957,7 +3957,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options return false; } if (st.permissions() != sf.permissions()) { - if (::fchmod(out, static_cast(sf.permissions() & perms::all)) != 0) { + if (::fchmod(out, static_cast(sf.permissions() & perms::all)) != 0) { ec = detail::make_system_error(); ::close(in); ::close(out);