diff options
| author | Nicolas Koch <nioko1337@gmail.com> | 2018-05-30 06:33:54 +0200 |
|---|---|---|
| committer | Nicolas Koch <nioko1337@gmail.com> | 2018-05-30 06:33:54 +0200 |
| commit | 9b6940d0b46284f24410050e9bfde0a9ab08d0fb (patch) | |
| tree | 52adc6bb31311c7c2559e7008dcc2b112b834963 /src/libstd/sys | |
| parent | 2408095f3456ba8974032e5dd0a2806cc7329cfb (diff) | |
| download | rust-9b6940d0b46284f24410050e9bfde0a9ab08d0fb.tar.gz rust-9b6940d0b46284f24410050e9bfde0a9ab08d0fb.zip | |
fs: copy: Use File::set_permissions instead of fs::set_permissions
We already got the open file descriptor at this point. Don't make the kernel resolve the path again.
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 889d21cad65..9d0d3779057 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -807,14 +807,14 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { let perm = reader.metadata()?.permissions(); let ret = io::copy(&mut reader, &mut writer)?; - set_permissions(to, perm)?; + writer.set_permissions(perm)?; Ok(ret) } #[cfg(any(target_os = "linux", target_os = "android"))] pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { use cmp; - use fs::{File, set_permissions}; + use fs::File; use sync::atomic::{AtomicBool, Ordering}; // Kernel prior to 4.5 don't have copy_file_range @@ -886,7 +886,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { // Try again with fallback method assert_eq!(written, 0); let ret = io::copy(&mut reader, &mut writer)?; - set_permissions(to, perm)?; + writer.set_permissions(perm)?; return Ok(ret) }, _ => return Err(err), @@ -894,6 +894,6 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { } } } - set_permissions(to, perm)?; + writer.set_permissions(perm)?; Ok(written) } |
