diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..25e4353 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "augmentator" +version = "0.1.0" diff --git a/src/main.rs b/src/main.rs index e7a11a9..6637cf6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,36 @@ -fn main() { - println!("Hello, world!"); +use std::io; +use std::path::{Path, PathBuf}; +use std::error::Error; + +fn get_image_paths(path: &Path) -> Result, Box> +{ + let mut full_paths: Vec = vec![]; + + path.read_dir()?.filter_map(|e| e.ok()).for_each(|file| + { + let filename = file.file_name().to_string_lossy().into_owned(); + if let Some(extension) = filename.split('.').last() + { + if extension == "jpg" || extension == "png" + { + full_paths.push(file.path().canonicalize().unwrap()); + } + } + }); + + Ok(full_paths) +} + +fn main() +{ + println!("Please enter the directory containing the images: "); + let mut buffer = String::new(); + let _ = io::stdin().read_line(&mut buffer); + + let paths = get_image_paths(Path::new(buffer.trim())) + .expect("Failed to gather image paths"); + + for path in paths { + println!("{}", path.display()); + } }