use crate::fs::DirectoryReader;
use crate::fs::*;
use colored::Colorize;
use log::trace;
use std::path::PathBuf;
pub struct Collector;
impl Collector {
#[must_use]
pub fn get_flacs(source_dir: &PathBuf) -> Vec<FlacFile> {
let paths = DirectoryReader::new()
.with_extension("flac")
.read(source_dir)
.expect("Source directory should be readable");
let mut collection = Vec::new();
for path in paths {
collection.push(FlacFile::new(path, source_dir));
}
trace!(
"{} {} flacs in: {:?}",
"Found".bold(),
collection.len(),
source_dir
);
collection
}
#[must_use]
pub fn get_additional(source_dir: &PathBuf) -> Vec<AdditionalFile> {
let paths = DirectoryReader::new()
.with_max_depth(0)
.with_extensions(vec!["jpg", "jpeg", "png"])
.read(source_dir)
.expect("Source directory should be readable");
let mut collection = Vec::new();
for path in paths {
collection.push(AdditionalFile::new(path, source_dir));
}
trace!(
"{} {} files in: {:?}",
"Found".bold(),
collection.len(),
source_dir
);
collection
}
}