X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/f6a545b00a4046879b7cc25c06c37bb6b6880b43..ce17f0a9b30a6a1b9eaf1b97ddbfc43355e5355a:/src/generator/static_files.rs diff --git a/src/generator/static_files.rs b/src/generator/static_files.rs index 50f56d8..401eacf 100644 --- a/src/generator/static_files.rs +++ b/src/generator/static_files.rs @@ -1,27 +1,7 @@ -use std::fs::{copy, create_dir_all, read_dir}; use std::io::Result; use std::path::PathBuf; use crate::template::TemplateContext; - -fn recursively_copy(source: &PathBuf, target: &PathBuf) -> Result<()> { - let entries = read_dir(source)?; - for entry in entries { - let entry = entry?; - let entry_type = entry.file_type()?; - let entry_name = entry.file_name(); - let entry_source = entry.path(); - let entry_target = target.join(entry_name); - - if entry_type.is_dir() { - create_dir_all(&entry_target)?; - recursively_copy(&entry_source, &entry_target)?; - } else { - copy(&entry_source, &entry_target)?; - } - } - - Ok(()) -} +use crate::utils::recursively_copy; pub fn generate(source: &PathBuf, _: &PathBuf, target: &PathBuf, _: &TemplateContext) -> Result<()> { if source.exists() {