From be092f37546dfb2ec297635c0f8e4b040189ca55 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 9 Jan 2017 22:16:47 -0700 Subject: [PATCH] Create parent directories --- src/{install/mod.rs => install.rs} | 4 ++++ 1 file changed, 4 insertions(+) rename src/{install/mod.rs => install.rs} (96%) diff --git a/src/install/mod.rs b/src/install.rs similarity index 96% rename from src/install/mod.rs rename to src/install.rs index a442ec0bbf..788f06998e 100644 --- a/src/install/mod.rs +++ b/src/install.rs @@ -142,6 +142,10 @@ pub fn install(config: Config) -> Result<(), String> { ($path:expr, $data:expr) => {{ let mut path = sysroot.clone(); path.push($path); + if let Some(parent) = path.parent() { + println!("Create file parent {}", parent.display()); + fs::create_dir_all(parent).map_err(|err| format!("failed to create file parent {}: {}", parent.display(), err))?; + } println!("Create file {}", path.display()); let mut file = fs::File::create(&path).map_err(|err| format!("failed to create {}: {}", path.display(), err))?; file.write_all($data).map_err(|err| format!("failed to write {}: {}", path.display(), err))?;