Skip to content

Commit

Permalink
Merge pull request #144 from actboy168/patch-2
Browse files Browse the repository at this point in the history
copy_file also copies permissions
  • Loading branch information
gulrak committed Mar 3, 2023
2 parents de64dec + 28f7c92 commit 3afbd9c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3967,6 +3967,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<mode_t>(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;
Expand Down

0 comments on commit 3afbd9c

Please sign in to comment.