From 5e28d9549b6e66882ed5b7b5aba7453c11f9f28f Mon Sep 17 00:00:00 2001 From: curly Date: Tue, 3 Jan 2023 15:24:26 -0700 Subject: hardcoded, but functional --- src/lib.rs | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 78d068b..344987d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 = vec![path::PathBuf::from("nav.html")]; + let dns: Vec = 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, }; -- cgit v1.2.3