summaryrefslogtreecommitdiffstats
path: root/src/libstd/sys/unix/fs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/sys/unix/fs.rs')
-rw-r--r--src/libstd/sys/unix/fs.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index c9d187f2ff..d8739d6532 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -815,7 +815,11 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
815 815
816 let mut written = 0u64; 816 let mut written = 0u64;
817 while written < len { 817 while written < len {
818 let bytes_to_copy = len - written; 818 let bytes_to_copy = if len - written > usize::max_value() as u64 {
819 usize::max_value()
820 } else {
821 (len - written) as usize
822 };
819 let copy_result = unsafe { 823 let copy_result = unsafe {
820 // We actually don't have to adjust the offsets, 824 // We actually don't have to adjust the offsets,
821 // because copy_file_range adjusts the file offset automatically 825 // because copy_file_range adjusts the file offset automatically
@@ -823,7 +827,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
823 ptr::null_mut(), 827 ptr::null_mut(),
824 writer.as_raw_fd(), 828 writer.as_raw_fd(),
825 ptr::null_mut(), 829 ptr::null_mut(),
826 bytes_to_copy as usize, 830 bytes_to_copy,
827 0) 831 0)
828 ) 832 )
829 }; 833 };