Skip to content

Commit b7908fe

Browse files
committed
Remove duplicate code by using util::copy()
1 parent 88c743d commit b7908fe

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/libstd/io/fs.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,8 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
381381

382382
let mut reader = try!(File::open(from));
383383
let mut writer = try!(File::create(to));
384-
let mut buf = [0, ..io::DEFAULT_BUF_SIZE];
385384

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-
}
385+
try!(super::util::copy(&mut reader, &mut writer));
394386

395387
chmod(to, try!(update_err(from.stat(), from, to)).perm)
396388
}

0 commit comments

Comments
 (0)