rollup merge of #19016: gkoz/use_util_copy
This code is identical to io::util::copy()
This commit is contained in:
commit
f1fd6b9407
1 changed files with 1 additions and 9 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue