mangofetch_core/
fs_paths.rs1use std::path::PathBuf;
2
3pub trait AppPaths: Send + Sync {
4 fn downloads_dir(&self) -> PathBuf;
5 fn data_dir(&self) -> PathBuf;
6 fn cache_dir(&self) -> PathBuf;
7 fn bin_dir(&self) -> Option<PathBuf>;
8}
9
10pub struct DesktopPaths;
11
12impl AppPaths for DesktopPaths {
13 fn downloads_dir(&self) -> PathBuf {
14 dirs::download_dir().unwrap_or_else(|| PathBuf::from("."))
15 }
16
17 fn data_dir(&self) -> PathBuf {
18 dirs::data_dir()
19 .map(|d| d.join("mangofetch"))
20 .unwrap_or_else(|| PathBuf::from("."))
21 }
22
23 fn cache_dir(&self) -> PathBuf {
24 dirs::cache_dir()
25 .map(|d| d.join("mangofetch"))
26 .unwrap_or_else(|| PathBuf::from("."))
27 }
28
29 fn bin_dir(&self) -> Option<PathBuf> {
30 dirs::data_dir().map(|d| d.join("mangofetch").join("bin"))
31 }
32}