Scaffholding for serving thumbnails
This commit is contained in:
parent
bb66b3a566
commit
61e4f6c7d2
5 changed files with 62 additions and 22 deletions
37
src/utils.rs
Normal file
37
src/utils.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
use std::path::Path;
|
||||
|
||||
pub fn is_song(path: &Path) -> bool {
|
||||
let extension = match path.extension() {
|
||||
Some(e) => e,
|
||||
_ => return false,
|
||||
};
|
||||
let extension = match extension.to_str() {
|
||||
Some(e) => e,
|
||||
_ => return false,
|
||||
};
|
||||
match extension {
|
||||
"mp3" => return true,
|
||||
"ogg" => return true,
|
||||
"m4a" => return true,
|
||||
"flac" => return true,
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_image(path: &Path) -> bool {
|
||||
let extension = match path.extension() {
|
||||
Some(e) => e,
|
||||
_ => return false,
|
||||
};
|
||||
let extension = match extension.to_str() {
|
||||
Some(e) => e,
|
||||
_ => return false,
|
||||
};
|
||||
match extension {
|
||||
"png" => return true,
|
||||
"gif" => return true,
|
||||
"jpg" => return true,
|
||||
"bmp" => return true,
|
||||
_ => return false,
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue