diff options
| author | Jakub Bukaj <jakub@jakub.cc> | 2014-11-18 00:24:03 +0100 |
|---|---|---|
| committer | Jakub Bukaj <jakub@jakub.cc> | 2014-11-18 00:24:03 +0100 |
| commit | f1fd6b940725bdf98147609c7cdb7fbf9bf3e29d (patch) | |
| tree | e9ef5488e0040c654888dd50bc1f963481af089d /src/libstd/io | |
| parent | 789777babda61ffbf257c85f58084c94c9f06866 (diff) | |
| parent | 8b16ccdd7b47a4c93d6357c800a221daaf8c7db4 (diff) | |
| download | rust-f1fd6b940725bdf98147609c7cdb7fbf9bf3e29d.tar.gz rust-f1fd6b940725bdf98147609c7cdb7fbf9bf3e29d.zip | |
rollup merge of #19016: gkoz/use_util_copy
This code is identical to io::util::copy()
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/fs.rs | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 3f39dda650a..cd4141e045c 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -381,16 +381,8 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> { let mut reader = try!(File::open(from)); let mut writer = try!(File::create(to)); - let mut buf = [0, ..io::DEFAULT_BUF_SIZE]; - loop { - let amt = match reader.read(&mut buf) { - Ok(n) => n, - Err(ref e) if e.kind == io::EndOfFile => { break } - Err(e) => return update_err(Err(e), from, to) - }; - try!(writer.write(buf[..amt])); - } + try!(update_err(super::util::copy(&mut reader, &mut writer), from, to)); chmod(to, try!(update_err(from.stat(), from, to)).perm) } |
