made function for creating parent directory
This commit is contained in:
@@ -36,9 +36,7 @@ pub fn docki_build(in_path: &str) -> DockiBuildResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn copy(in_path: &str, out_path: &str) -> Result<(), String> {
|
fn copy(in_path: &str, out_path: &str) -> Result<(), String> {
|
||||||
let segments: &Vec<&str> = &out_path.split("/").collect();
|
fs_util::create_parent_dir_recursive(out_path);
|
||||||
let parent_dir = &segments[0..segments.len() - 1].join("/");
|
|
||||||
fs_util::create_dir_recursive(parent_dir);
|
|
||||||
|
|
||||||
if let Err(err) = fs::copy(in_path, out_path) {
|
if let Err(err) = fs::copy(in_path, out_path) {
|
||||||
return Err(err.to_string())
|
return Err(err.to_string())
|
||||||
|
|||||||
@@ -83,3 +83,9 @@ pub fn docki_path_env() -> String {
|
|||||||
return expand_path(format!("{}:~/.docki/", current));
|
return expand_path(format!("{}:~/.docki/", current));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_parent_dir_recursive(out_path: &str) -> () {
|
||||||
|
let segments: &Vec<&str> = &out_path.split("/").collect();
|
||||||
|
let parent_dir = &segments[0..segments.len() - 1].join("/");
|
||||||
|
create_dir_recursive(parent_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user