Skip to content
Snippets Groups Projects
Verified Commit 0c731043 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Use fs::copy to ensure metadata is copied

parent 2c54a9b8
No related branches found
No related tags found
No related merge requests found
...@@ -313,53 +313,13 @@ fn main() { ...@@ -313,53 +313,13 @@ fn main() {
} }
} }
//TODO: match file type to support symlinks match fs::copy(&src, &dest) {
Ok(ok) => (),
{ Err(err) => {
let mut src_file = match fs::File::open(&src) { eprintln!("installer_tui: failed to copy file {} to {}: {}", src, dest.display(), err);
Ok(ok) => ok, return Err(failure::Error::from_boxed_compat(
Err(err) => { Box::new(err))
eprintln!("installer_tui: failed to open file {}: {}", src, err); );
return Err(failure::Error::from_boxed_compat(
Box::new(err))
);
}
};
let mut dest_file = match fs::File::create(&dest) {
Ok(ok) => ok,
Err(err) => {
eprintln!("installer_tui: failed to create file {}: {}", dest.display(), err);
return Err(failure::Error::from_boxed_compat(
Box::new(err))
);
}
};
loop {
let count = match src_file.read(&mut buf) {
Ok(ok) => ok,
Err(err) => {
eprintln!("installer_tui: failed to read file {}: {}", src, err);
return Err(failure::Error::from_boxed_compat(
Box::new(err))
);
}
};
if count == 0 {
break;
}
match dest_file.write_all(&buf[..count]) {
Ok(()) => (),
Err(err) => {
eprintln!("installer_tui: failed to write file {}: {}", dest.display(), err);
return Err(failure::Error::from_boxed_compat(
Box::new(err))
);
}
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment