diff --git a/src/main.rs b/src/main.rs index def5033..59fe259 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,11 @@ fn home_dir() -> PathBuf { } fn downloads_dir() -> PathBuf { - dirs::download_dir().expect("Couldn't find download dir") + dirs::download_dir().expect("Couldn't find downloads dir") +} + +fn pictures_dir() -> PathBuf { + dirs::picture_dir().expect("Couldn't find pictures dir") } fn strip_null_bytes(str: &str) -> String { @@ -46,6 +50,19 @@ fn yes() -> bool { answer.to_lowercase().starts_with("y") } +fn handle_image(file: DirEntry) { + move_file(file.path(), pictures_dir()); +} + +fn handle_gif(file: DirEntry) { + let mut dir = pictures_dir(); + + dir.push("Internet"); + dir.push("GIFs"); + + move_file(file.path(), dir); +} + fn handle_mp3(file: DirEntry) { let meta = mp3_metadata::read_from_file(file.path()).unwrap(); @@ -85,11 +102,11 @@ fn handle_dir(path: PathBuf) { } match inode.path().extension().unwrap_or("none".as_ref()).to_str() { - Some("gif") => { /*println!("Here's where we would move things to ~/Pictures");*/ } - Some("jpg") => { /*println!("Here's where we would move things to ~/Pictures");*/ } - Some("jpeg") => { /*println!("Here's where we would move things to ~/Pictures");*/ } - Some("png") => { /*println!("Here's where we would move things to ~/Pictures");*/ } - Some("mp3") => { handle_mp3(inode) } + Some("gif") => { handle_gif( inode) } + Some("jpg") => { handle_image(inode) } + Some("jpeg") => { handle_image(inode) } + Some("png") => { handle_image(inode) } + Some("mp3") => { handle_mp3( inode) } // todo m4a, flac, etc? _ => { /*println!("Here's where we would do nothing.");*/ } }