util stuff into single file

master
rascul 5 years ago
parent bc4315762c
commit 5abbf991d9

@ -1,4 +1,4 @@
use std::fs::{metadata, set_permissions, Permissions}; use std::fs::{copy, create_dir, metadata, set_permissions, Permissions};
use std::path::PathBuf; use std::path::PathBuf;
use crate::error::*; use crate::error::*;
@ -25,3 +25,28 @@ pub fn set_perms(path: &PathBuf, perms: Permissions) -> MkrootResult<()> {
Ok(()) Ok(())
} }
pub fn mkdir(dir: &PathBuf) -> MkrootResult<()> {
if let Err(e) = create_dir(&dir) {
return Err(MkrootError::from(format!(
"Error creating directory {}: {}",
&dir.display(),
e
)));
}
Ok(())
}
pub fn copy_file(src: &PathBuf, dst: &PathBuf) -> MkrootResult<()> {
if let Err(e) = copy(&src, &dst) {
return Err(MkrootError::from(format!(
"Error copying file from {} to {}: {}",
&src.display(),
&dst.display(),
e
)));
}
Ok(())
}

@ -1,17 +0,0 @@
use std::fs::copy;
use std::path::PathBuf;
use crate::error::*;
pub fn copy_file(src: &PathBuf, dst: &PathBuf) -> MkrootResult<()> {
if let Err(e) = copy(&src, &dst) {
return Err(MkrootError::from(format!(
"Error copying file from {} to {}: {}",
&src.display(),
&dst.display(),
e
)));
}
Ok(())
}

@ -1,16 +0,0 @@
use std::fs::create_dir;
use std::path::PathBuf;
use crate::error::*;
pub fn mkdir(dir: &PathBuf) -> MkrootResult<()> {
if let Err(e) = create_dir(&dir) {
return Err(MkrootError::from(format!(
"Error creating directory {}: {}",
&dir.display(),
e
)));
}
Ok(())
}

@ -1,7 +0,0 @@
mod copy_file;
mod mkdir;
mod perms;
pub use crate::util::copy_file::copy_file;
pub use crate::util::mkdir::mkdir;
pub use crate::util::perms::*;
Loading…
Cancel
Save