|
|
@ -1,9 +1,10 @@
|
|
|
|
use std::fs::{copy as fscopy, create_dir, metadata, read_dir, set_permissions, Permissions};
|
|
|
|
use std::fs::{copy as fscopy, create_dir, read_dir};
|
|
|
|
use std::os::unix::fs::PermissionsExt;
|
|
|
|
use std::os::unix::fs::PermissionsExt;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::config::Config;
|
|
|
|
use crate::config::Config;
|
|
|
|
use crate::error::*;
|
|
|
|
use crate::error::*;
|
|
|
|
|
|
|
|
use crate::util::{get_perms, set_perms};
|
|
|
|
|
|
|
|
|
|
|
|
pub fn copy(config: &Config) -> MkrootResult<()> {
|
|
|
|
pub fn copy(config: &Config) -> MkrootResult<()> {
|
|
|
|
if config.verbose {
|
|
|
|
if config.verbose {
|
|
|
@ -104,30 +105,6 @@ fn copy_file(src: &PathBuf, dst: &PathBuf) -> MkrootResult<()> {
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn get_perms(path: &PathBuf) -> MkrootResult<Permissions> {
|
|
|
|
|
|
|
|
match metadata(path) {
|
|
|
|
|
|
|
|
Ok(meta) => Ok(meta.permissions()),
|
|
|
|
|
|
|
|
Err(e) => Err(MkrootError::from(format!(
|
|
|
|
|
|
|
|
"Error retrieving metadata {}: {}",
|
|
|
|
|
|
|
|
path.display(),
|
|
|
|
|
|
|
|
e
|
|
|
|
|
|
|
|
))),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn set_perms(path: &PathBuf, perms: Permissions) -> MkrootResult<()> {
|
|
|
|
|
|
|
|
if let Err(e) = set_permissions(path, perms) {
|
|
|
|
|
|
|
|
return Err(MkrootError::from(format!(
|
|
|
|
|
|
|
|
"Error setting permissions {}: {}",
|
|
|
|
|
|
|
|
path.display(),
|
|
|
|
|
|
|
|
e
|
|
|
|
|
|
|
|
)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn mkdir(path: &PathBuf) -> MkrootResult<()> {
|
|
|
|
fn mkdir(path: &PathBuf) -> MkrootResult<()> {
|
|
|
|
if let Err(e) = create_dir(path) {
|
|
|
|
if let Err(e) = create_dir(path) {
|
|
|
|
return Err(MkrootError::from(format!(
|
|
|
|
return Err(MkrootError::from(format!(
|
|
|
|