Skip to content

Commit

Permalink
Fix large file copies on 32 bit platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokoch committed May 16, 2018
1 parent f4c2825 commit a5e2942
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libstd/sys/unix/fs.rs
Expand Up @@ -815,15 +815,19 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {

let mut written = 0u64;
while written < len {
let bytes_to_copy = len - written;
let bytes_to_copy = if len - written > usize::max_value() as u64 {
usize::max_value()
} else {
(len - written) as usize
};
let copy_result = unsafe {
// We actually don't have to adjust the offsets,
// because copy_file_range adjusts the file offset automatically
cvt(copy_file_range(reader.as_raw_fd(),
ptr::null_mut(),
writer.as_raw_fd(),
ptr::null_mut(),
bytes_to_copy as usize,
bytes_to_copy,
0)
)
};
Expand Down

0 comments on commit a5e2942

Please sign in to comment.