on master help sign in
removed compile errors and warnings on non-macs
commit05e2c2c66b80806d42c90175e23c833766e3ced5 authorLavi <lavifb@gmail.com> dateTue 5 Feb 2019, 14:34 (8 years ago) parent6922722
1 file changed+8−4
src/dirs.rs+8−4
src/dirs.rs+8−4
@@ -1,7 +1,10 @@
1−use dirs_rs::home_dir;
1+use dirs_rs;
2+use std::path::{Path, PathBuf};
3+
4+#[cfg(target_os = "macos")]
25use std::env;
6+#[cfg(target_os = "macos")]
37use std::ffi::OsString;
4−use std::path::{Path, PathBuf};
58
69/// Wrapper for dirs that treats MacOS more like Linux.
710/// First, env variables `XDG_CACHE_HOME` and `XDG_CONFIG_HOME` are checked and the fall back is
@@ -16,7 +19,7 @@ impl BatProjectDirs {
1619 #[cfg(target_os = "macos")]
1720 let cache_dir_op = env::var_os("XDG_CACHE_HOME")
1821 .and_then(is_absolute_path)
19− .or_else(|| home_dir().map(|d| d.join(".cache")));
22+ .or_else(|| dirs_rs::home_dir().map(|d| d.join(".cache")));
2023
2124 #[cfg(not(target_os = "macos"))]
2225 let cache_dir_op = dirs_rs::cache_dir();
@@ -29,7 +32,7 @@ impl BatProjectDirs {
2932 #[cfg(target_os = "macos")]
3033 let config_dir_op = env::var_os("XDG_CONFIG_HOME")
3134 .and_then(is_absolute_path)
32− .or_else(|| home_dir().map(|d| d.join(".config")));
35+ .or_else(|| dirs_rs::home_dir().map(|d| d.join(".config")));
3336
3437 #[cfg(not(target_os = "macos"))]
3538 let config_dir_op = dirs_rs::config_dir();
@@ -55,6 +58,7 @@ impl BatProjectDirs {
5558}
5659
5760// Returns path if it is an absolute path
61+#[cfg(target_os = "macos")]
5862fn is_absolute_path(path: OsString) -> Option<PathBuf> {
5963 let path = PathBuf::from(path);
6064 if path.is_absolute() {