tsk-44 #47
@@ -1,5 +1,5 @@
|
|||||||
/// Gets the file type of a CoverArt given it's path
|
/// Gets the file type of a CoverArt given it's path
|
||||||
pub fn file_type(filepath: &str) -> Result<String, std::io::Error> {
|
pub fn file_type_from_filepath(filepath: &str) -> Result<String, std::io::Error> {
|
||||||
match imghdr::from_file(filepath) {
|
match imghdr::from_file(filepath) {
|
||||||
Ok(Some(imghdr::Type::Jpeg)) => Ok(String::from("jpeg")),
|
Ok(Some(imghdr::Type::Jpeg)) => Ok(String::from("jpeg")),
|
||||||
Ok(Some(imghdr::Type::Png)) => Ok(String::from("png")),
|
Ok(Some(imghdr::Type::Png)) => Ok(String::from("png")),
|
||||||
@@ -27,7 +27,7 @@ mod tests {
|
|||||||
let filename = String::from("Sample Tracks 3.png");
|
let filename = String::from("Sample Tracks 3.png");
|
||||||
let filepath = format!("{directory}/{filename}");
|
let filepath = format!("{directory}/{filename}");
|
||||||
|
|
||||||
match super::file_type(&filepath) {
|
match super::file_type_from_filepath(&filepath) {
|
||||||
Ok(filetype) => {
|
Ok(filetype) => {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
filetype, "png",
|
filetype, "png",
|
||||||
|
|||||||
Reference in New Issue
Block a user