File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,16 @@ pub fn home_dir() -> Option<PathBuf> {
101
101
std:: env:: var ( "HOME" ) . map ( PathBuf :: from) . ok ( )
102
102
}
103
103
104
+ /// Tries to obtain the home directory from `HOME` on all platforms, but falls back to [`home::home_dir()`] for
105
+ /// more complex ways of obtaining a home directory, particularly useful on Windows.
106
+ ///
107
+ /// The reason `HOME` is tried first is to allow Windows users to have a custom location for their linux-style
108
+ /// home, as otherwise they would have to accumulate dot files in a directory these are inconvenient and perceived
109
+ /// as clutter.
104
110
#[ cfg( not( target_family = "wasm" ) ) ]
105
- pub use home:: home_dir;
111
+ pub fn home_dir ( ) -> Option < PathBuf > {
112
+ std:: env:: var_os ( "HOME" ) . map ( Into :: into) . or_else ( home:: home_dir)
113
+ }
106
114
107
115
/// Returns the contents of an environment variable of `name` with some special handling
108
116
/// for certain environment variables (like `HOME`) for platform compatibility.
You can’t perform that action at this time.
0 commit comments