use util functions

master
rascul 5 years ago
parent 8d8f842fb6
commit a172f4c645

@ -1,4 +1,4 @@
use std::fs::{copy as fscopy, metadata, set_permissions, File}; use std::fs::{copy as fscopy, File, Permissions};
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
@ -7,6 +7,7 @@ use regex::Regex;
use crate::config::Config; use crate::config::Config;
use crate::error::*; use crate::error::*;
use crate::util::set_perms;
pub struct Files { pub struct Files {
pub bins: Vec<PathBuf>, pub bins: Vec<PathBuf>,
@ -191,28 +192,7 @@ impl Files {
println!("Setting linker {} to mode 0o755", &lib.display()); println!("Setting linker {} to mode 0o755", &lib.display());
} }
match metadata(&lib) { set_perms(&lib, Permissions::from_mode(0o755))?;
Ok(meta) => {
let mut perms = meta.permissions();
perms.set_mode(0o755);
if let Err(e) = set_permissions(&lib, perms) {
return Err(MkrootError::from(format!(
"Error setting permissions {}: {}",
&lib.display(),
e
)));
} else {
return Ok(());
}
}
Err(e) => {
return Err(MkrootError::from(format!(
"Error reading metadata {}: {}",
&lib.display(),
e
)))
}
}
} }
} }
} }
@ -244,9 +224,7 @@ impl Files {
e e
))); )));
} else { } else {
let mut perms = metadata(&t)?.permissions(); set_perms(&t, Permissions::from_mode(mode))?;
perms.set_mode(mode);
set_permissions(&t, perms)?;
} }
} else if verbose { } else if verbose {
println!("Skipping {}", &f.display()); println!("Skipping {}", &f.display());

Loading…
Cancel
Save