selene_core/config/
core_impls.rs1use std::{fs, io::Read, path::PathBuf};
2
3use lunar_lib::config::Config;
4
5use crate::{
6 config::CommonConfig, media_container::ContainerFormat, utils::recurse_list_from_root,
7};
8
9impl Config for CommonConfig {
11 const CONFIG_FILE_NAME: &'static str = "common";
12
13 fn config_dir() -> PathBuf {
14 crate::config_dir().to_owned()
15 }
16}
17
18impl CommonConfig {
20 #[must_use]
22 pub(crate) fn get_source_files(&self) -> Vec<PathBuf> {
23 self.main
24 .source_directories
25 .iter()
26 .flat_map(|path| -> Vec<PathBuf> {
27 recurse_list_from_root(path, false)
28 .filter_map(|f| {
29 let mut file = fs::File::open(&f).ok()?;
30 let mut buf = [0_u8; 16];
31 file.read_exact(&mut buf).ok()?;
32 ContainerFormat::from_buf(&buf)?;
33 Some(f)
34 })
35 .collect()
36 })
37 .collect()
38 }
39}