Merge pull request #144 from actboy168/patch-2

copy_file also copies permissions
This commit is contained in:
gulrak 2023-03-03 17:35:47 +01:00 committed by GitHub
commit 3afbd9c315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3967,6 +3967,14 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
::close(in); ::close(in);
return false; 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; ssize_t br, bw;
while ((br = ::read(in, buffer.data(), buffer.size())) > 0) { while ((br = ::read(in, buffer.data(), buffer.size())) > 0) {
ssize_t offset = 0; ssize_t offset = 0;