~/website

9226e0e390cd324e4a7c288e0aa27a23b4698065 — Arthur Melton 27cfe2af 2 years ago
make parent folders
1 files changed, 8 insertions(+), 0 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +8 -0
@@ 31,6 31,10 @@ fn main() {

        if e.metadata().unwrap().is_file() {
            let mut path = e.path();
            path = path.strip_prefix("static/").unwrap(); // should never fail
            let mut parent = path.to_path_buf();
            parent.pop();
            fs::create_dir_all(parent.clone())
                .unwrap_or_else(|_| panic!("Cant make the folders {}", parent.display()));
            fs::copy(e.path(), Path::new("public").join(path)).unwrap_or_else(|_| {
                panic!(
                    "failed to copy static/{} to public/{}",

@@ 73,6 77,10 @@ fn main() {

            let path = Path::new("public")
                .join(path.strip_prefix("pages").unwrap())
                .with_extension("html");
            let mut parent = path.to_path_buf();
            parent.pop();
            fs::create_dir_all(parent.clone())
                .unwrap_or_else(|_| panic!("Cant make the folders {}", parent.display()));
            let mut file = File::create(path.clone())
                .unwrap_or_else(|_| panic!("Cant make file {}", path.display()));
            file.write_all(