1
Fork 0

Remove duplicate code by using util::copy()

This commit is contained in:
Gleb Kozyrev 2014-11-17 02:07:23 +02:00
parent 88c743def3
commit b7908febca

View file

@ -381,16 +381,8 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
let mut reader = try!(File::open(from)); let mut reader = try!(File::open(from));
let mut writer = try!(File::create(to)); let mut writer = try!(File::create(to));
let mut buf = [0, ..io::DEFAULT_BUF_SIZE];
loop { try!(super::util::copy(&mut reader, &mut writer));
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]));
}
chmod(to, try!(update_err(from.stat(), from, to)).perm) chmod(to, try!(update_err(from.stat(), from, to)).perm)
} }