-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The home crate also accesses global process state, so we need to abstract over it as well.
- Loading branch information
1 parent
2880f30
commit 0997247
Showing
5 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// Adapts currentprocess to the trait home::Env | ||
use std::ffi::OsString; | ||
use std::io; | ||
use std::ops::Deref; | ||
use std::path::PathBuf; | ||
|
||
use super::CurrentDirSource; | ||
use super::CurrentProcess; | ||
use super::VarSource; | ||
|
||
impl home::Env for Box<dyn CurrentProcess + 'static> { | ||
fn home_dir(&self) -> Option<PathBuf> { | ||
self.var("HOME").ok().map(|v| v.into()) | ||
} | ||
fn current_dir(&self) -> Result<PathBuf, io::Error> { | ||
CurrentDirSource::current_dir(self.deref()) | ||
} | ||
fn var_os(&self, key: &str) -> Option<OsString> { | ||
VarSource::var_os(self.deref(), key) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters