freedesktop_core/lib.rs
1pub mod info;
2use std::path::PathBuf;
3
4/// The base directories all other searches are
5/// based on. Data comes from XDG_DATA_DIRS
6pub fn base_directories() -> Vec<PathBuf> {
7 let mut dirs: Vec<PathBuf> = Vec::new();
8
9 if let Ok(var_str) = std::env::var("XDG_DATA_DIRS") {
10 for p in var_str.split(":") {
11 let pb = PathBuf::from(p);
12
13 if pb.exists() {
14 dirs.push(pb);
15 }
16 }
17 }
18
19 if let Ok(var_str) = std::env::var("XDG_DATA_HOME") {
20 let pb = PathBuf::from(var_str);
21
22 if pb.exists() {
23 dirs.push(pb);
24 }
25 }
26
27 dirs
28}