parent
b971b362c2
commit
eb739c9ff9
2 changed files with 20 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
### Version 0.19.1 (unreleased)
|
### Version 0.19.1 (unreleased)
|
||||||
- Refactor of internal code.
|
- Refactor of internal code.
|
||||||
|
- Implement unix-specific permissions copying for `-p` option
|
||||||
|
|
||||||
### Version 0.19.0
|
### Version 0.19.0
|
||||||
- [SEMVER_MAJOR] Default to overwriting the input file if `out_file` is not set.
|
- [SEMVER_MAJOR] Default to overwriting the input file if `out_file` is not set.
|
||||||
|
|
|
||||||
22
src/lib.rs
22
src/lib.rs
|
|
@ -713,12 +713,10 @@ fn perform_backup(input_path: &Path) -> Result<(), PngError> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(unix))]
|
||||||
fn copy_permissions(input_path: &Path, out_file: &File, verbosity: Option<u8>) {
|
fn copy_permissions(input_path: &Path, out_file: &File, verbosity: Option<u8>) {
|
||||||
if let Ok(f) = File::open(input_path) {
|
if let Ok(f) = File::open(input_path) {
|
||||||
if let Ok(metadata) = f.metadata() {
|
if let Ok(metadata) = f.metadata() {
|
||||||
// TODO: Implement full permission changing on Unix
|
|
||||||
// Not available in stable, requires block cfg statements
|
|
||||||
// See https://github.com/rust-lang/rust/issues/15701
|
|
||||||
if let Ok(out_meta) = out_file.metadata() {
|
if let Ok(out_meta) = out_file.metadata() {
|
||||||
let readonly = metadata.permissions().readonly();
|
let readonly = metadata.permissions().readonly();
|
||||||
out_meta.permissions().set_readonly(readonly);
|
out_meta.permissions().set_readonly(readonly);
|
||||||
|
|
@ -731,6 +729,24 @@ fn copy_permissions(input_path: &Path, out_file: &File, verbosity: Option<u8>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn copy_permissions(input_path: &Path, out_file: &File, verbosity: Option<u8>) {
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
|
if let Ok(f) = File::open(input_path) {
|
||||||
|
if let Ok(metadata) = f.metadata() {
|
||||||
|
if let Ok(out_meta) = out_file.metadata() {
|
||||||
|
let permissions = metadata.permissions().mode();
|
||||||
|
out_meta.permissions().set_mode(permissions);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if verbosity.is_some() {
|
||||||
|
eprintln!("Failed to set permissions on output file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn image_to_pixel_array(image: &DynamicImage) -> Vec<Vec<u8>> {
|
fn image_to_pixel_array(image: &DynamicImage) -> Vec<Vec<u8>> {
|
||||||
image
|
image
|
||||||
.pixels()
|
.pixels()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue