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 88c743d commit b7908feCopy full SHA for b7908fe
src/libstd/io/fs.rs
@@ -381,16 +381,8 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
381
382
let mut reader = try!(File::open(from));
383
let mut writer = try!(File::create(to));
384
- let mut buf = [0, ..io::DEFAULT_BUF_SIZE];
385
386
- loop {
387
- let amt = match reader.read(&mut buf) {
388
- Ok(n) => n,
389
- Err(ref e) if e.kind == io::EndOfFile => { break }
390
- Err(e) => return update_err(Err(e), from, to)
391
- };
392
- try!(writer.write(buf[..amt]));
393
- }
+ try!(super::util::copy(&mut reader, &mut writer));
394
395
chmod(to, try!(update_err(from.stat(), from, to)).perm)
396
}
0 commit comments