tsk-44: Added function to get CoverArt type from data

This commit is contained in:
2025-10-21 12:08:55 -04:00
parent 2019269ded
commit f20b16e59f
2 changed files with 48 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ pub mod types;
pub mod test_util {
pub mod util {
use std::io::{self, Write};
use std::io::{self, Read, Write};
use rand::Rng;
@@ -39,6 +39,23 @@ pub mod test_util {
std::fs::copy(src_path, dest_path)
}
pub fn get_data_from_file(source_path: &str) -> Result<Vec<u8>, std::io::Error> {
match std::fs::File::open(source_path) {
Ok(mut file) => {
let mut data: Vec<u8> = Vec::new();
match file.read_to_end(&mut data) {
Ok(_) => {
Ok(data)
}
Err(err) => Err(err)
}
}
Err(err) => {
Err(err)
}
}
}
pub fn file_exists(directory: &String, filename: &String) -> Result<bool, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.exists()),