diff options
| author | Gleb Kozyrev <gleb@gkoz.com> | 2014-11-17 02:07:23 +0200 |
|---|---|---|
| committer | Gleb Kozyrev <gleb@gkoz.com> | 2014-11-17 19:18:26 +0200 |
| commit | b7908febca68700b4c14be5b55e4121e9f9ddb06 (patch) | |
| tree | 512b96ba903d8c3de17984386b7cba62f9118735 /src/libstd | |
| parent | 88c743def3cf42ee943ca09dda1e6dccf4894db9 (diff) | |
| download | rust-b7908febca68700b4c14be5b55e4121e9f9ddb06.tar.gz rust-b7908febca68700b4c14be5b55e4121e9f9ddb06.zip | |
Remove duplicate code by using util::copy()
Diffstat (limited to 'src/libstd')
| -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..f4e795721cf 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!(super::util::copy(&mut reader, &mut writer)); chmod(to, try!(update_err(from.stat(), from, to)).perm) } |
