We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f4c2825 commit a5e2942Copy full SHA for a5e2942
src/libstd/sys/unix/fs.rs
@@ -815,15 +815,19 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
815
816
let mut written = 0u64;
817
while written < len {
818
- let bytes_to_copy = len - written;
+ let bytes_to_copy = if len - written > usize::max_value() as u64 {
819
+ usize::max_value()
820
+ } else {
821
+ (len - written) as usize
822
+ };
823
let copy_result = unsafe {
824
// We actually don't have to adjust the offsets,
825
// because copy_file_range adjusts the file offset automatically
826
cvt(copy_file_range(reader.as_raw_fd(),
827
ptr::null_mut(),
828
writer.as_raw_fd(),
829
- bytes_to_copy as usize,
830
+ bytes_to_copy,
831
0)
832
)
833
};
0 commit comments