@@ -18,7 +18,8 @@ impl BatProjectDirs {
18 fn new() -> Option<BatProjectDirs> {
18 fn new() -> Option<BatProjectDirs> {
19 #[cfg(target_os = "macos")]
19 #[cfg(target_os = "macos")]
20 let cache_dir_op = env::var_os("XDG_CACHE_HOME")
20 let cache_dir_op = env::var_os("XDG_CACHE_HOME")
21− .and_then(is_absolute_path)
21+ .map(PathBuf::from)
22+ .filter(|p| p.is_absolute())
22 .or_else(|| dirs_rs::home_dir().map(|d| d.join(".cache")));
23 .or_else(|| dirs_rs::home_dir().map(|d| d.join(".cache")));
24 #[cfg(not(target_os = "macos"))]
25 #[cfg(not(target_os = "macos"))]
@@ -31,7 +32,8 @@ impl BatProjectDirs {
32 #[cfg(target_os = "macos")]
33 #[cfg(target_os = "macos")]
33 let config_dir_op = env::var_os("XDG_CONFIG_HOME")
34 let config_dir_op = env::var_os("XDG_CONFIG_HOME")
34− .and_then(is_absolute_path)
35+ .map(PathBuf::from)
36+ .filter(|p| p.is_absolute())
35 .or_else(|| dirs_rs::home_dir().map(|d| d.join(".config")));
37 .or_else(|| dirs_rs::home_dir().map(|d| d.join(".config")));
37 #[cfg(not(target_os = "macos"))]
39 #[cfg(not(target_os = "macos"))]
@@ -57,17 +59,6 @@ impl BatProjectDirs {
60−// Returns path if it is an absolute path
61−#[cfg(target_os = "macos")]
62−fn is_absolute_path(path: OsString) -> Option<PathBuf> {
63− let path = PathBuf::from(path);
64− if path.is_absolute() {
71lazy_static! {
62lazy_static! {
72 pub static ref PROJECT_DIRS: BatProjectDirs =
63 pub static ref PROJECT_DIRS: BatProjectDirs =
73 BatProjectDirs::new().expect("Could not get home directory");
64 BatProjectDirs::new().expect("Could not get home directory");