use super::{content_path, output_path}; use std::fs; use std::path::PathBuf; pub fn copy() { copy_recursively(content_path("static"), &mut output_path(".")); } fn copy_recursively(source: PathBuf, dest: &mut PathBuf) { for entry in fs::read_dir(source).unwrap() { let entry = entry.unwrap(); let ty = entry.file_type().unwrap(); if ty.is_symlink() { panic!( "symlinks are unsupported in site/static: {}", entry.path().display() ); } else if ty.is_dir() { dest.push(entry.file_name()); fs::create_dir_all(&dest).expect("create dir"); copy_recursively(entry.path(), dest); dest.pop(); } else if ty.is_file() { dest.push(entry.file_name()); fs::copy(entry.path(), &dest).expect("copy file"); dest.pop(); } } }