diff options
author | curly <curlybryce@protonmail.com> | 2023-01-03 15:24:26 -0700 |
---|---|---|
committer | curly <curlybryce@protonmail.com> | 2023-01-03 15:24:26 -0700 |
commit | 5e28d9549b6e66882ed5b7b5aba7453c11f9f28f (patch) | |
tree | 66b326ed8a625aa12e7b4fc390b394cd7d3e1e69 /src/lib.rs | |
parent | 6c3ab59c9acdc9528786993f47d225358e8b951a (diff) | |
download | s3g-5e28d9549b6e66882ed5b7b5aba7453c11f9f28f.tar.gz s3g-5e28d9549b6e66882ed5b7b5aba7453c11f9f28f.tar.bz2 s3g-5e28d9549b6e66882ed5b7b5aba7453c11f9f28f.zip |
hardcoded, but functional
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 46 |
1 files changed, 31 insertions, 15 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, }; |