image handling
This commit is contained in:
parent
3b9789235d
commit
8d584d2af1
29
src/main.rs
29
src/main.rs
|
@ -7,7 +7,11 @@ fn home_dir() -> PathBuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn downloads_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 {
|
fn strip_null_bytes(str: &str) -> String {
|
||||||
|
@ -46,6 +50,19 @@ fn yes() -> bool {
|
||||||
answer.to_lowercase().starts_with("y")
|
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) {
|
fn handle_mp3(file: DirEntry) {
|
||||||
let meta = mp3_metadata::read_from_file(file.path()).unwrap();
|
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() {
|
match inode.path().extension().unwrap_or("none".as_ref()).to_str() {
|
||||||
Some("gif") => { /*println!("Here's where we would move things to ~/Pictures");*/ }
|
Some("gif") => { handle_gif( inode) }
|
||||||
Some("jpg") => { /*println!("Here's where we would move things to ~/Pictures");*/ }
|
Some("jpg") => { handle_image(inode) }
|
||||||
Some("jpeg") => { /*println!("Here's where we would move things to ~/Pictures");*/ }
|
Some("jpeg") => { handle_image(inode) }
|
||||||
Some("png") => { /*println!("Here's where we would move things to ~/Pictures");*/ }
|
Some("png") => { handle_image(inode) }
|
||||||
Some("mp3") => { handle_mp3(inode) }
|
Some("mp3") => { handle_mp3( inode) }
|
||||||
// todo m4a, flac, etc?
|
// todo m4a, flac, etc?
|
||||||
_ => { /*println!("Here's where we would do nothing.");*/ }
|
_ => { /*println!("Here's where we would do nothing.");*/ }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue