diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 46 | ||||
-rw-r--r-- | src/main.rs | 6 |
2 files changed, 34 insertions, 18 deletions
@@ -121,27 +121,43 @@ pub fn run(config: Config) { fn check_path(path: &path::PathBuf, config: &Config) -> PathType { // GET EXCLUDE AND DNS LISTS + let excludes: Vec<path::PathBuf> = vec![path::PathBuf::from("nav.html")]; + let dns: Vec<path::PathBuf> = vec![path::PathBuf::from("assets/")]; + + // Convert path to str for comparisons + let path = path.to_str().unwrap(); // CHECK FOR EXCLUDES AND DO NOT SCANS // Excludes - // for ex_path in excludes { - // if &ex_path == &path { - // return PathType::Exclude; - // } - // } - - // // Do not scans (copy files) - // for dns_path in dns { - // if &dns_path == &path { + for ex_path in excludes { + let ex_path = ex_path.to_str().unwrap(); + if &path.contains(&ex_path) == &true { + return PathType::Exclude; + } + } - // return PathType::DoNotScan; - // } - // } + // Do not scans (copy files) + for dns_path in dns { + let dns_path = dns_path.to_str().unwrap(); + if &path.contains(&dns_path) == &true { + return PathType::DoNotScan; + } + } - PathType::Exclude + return PathType::Okay; } -fn copy_file(path: &path::PathBuf) {} +fn copy_file(path: &path::PathBuf, config: &Config) { + let build_path = replace_path_head(&path, "build/"); + match fs::copy(path, build_path) { + Ok(_) => (), + Err(n) => { + if n.kind() != ErrorKind::AlreadyExists { + panic!() + } + }, + } +} fn directory_scan(path: path::PathBuf, config: &Config) { println!("Scanning: {:?}", &path); @@ -173,7 +189,7 @@ fn file_scan(path: path::PathBuf, config: &Config) { // Check path match check_path(&path, config) { PathType::Okay => (), - PathType::DoNotScan => {copy_file(&path); return}, + PathType::DoNotScan => {copy_file(&path, &config); return}, PathType::Exclude => return, }; diff --git a/src/main.rs b/src/main.rs index 9f24daf..3b75b65 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,10 @@ use std::fs; fn main() { let config = match fs::read_to_string("settings.toml") { - Ok(n) => simple_static_site_generator::Config::import(&(n.as_str())), - Err(n) => {print!("\"settings.toml\": {}: ", n); simple_static_site_generator::Config::new()}, + Ok(n) => s3g::Config::import(&(n.as_str())), + Err(n) => {print!("\"settings.toml\": {}: ", n); s3g::Config::new()}, }; // Run - simple_static_site_generator::run(config); + s3g::run(config); }
\ No newline at end of file |