diff options
| author | Jeremy Soller <jackpot51@gmail.com> | 2016-11-14 19:08:48 -0700 |
|---|---|---|
| committer | Jeremy Soller <jackpot51@gmail.com> | 2016-11-14 19:08:48 -0700 |
| commit | de68aced95ab53bc0f69ff4d6867a03d2dd0f8d7 (patch) | |
| tree | 845f52896a3fcedebfd0876f875fb4a4b1c39b54 /src/libstd/sys | |
| parent | 18bf0540bf8a04a5724dd515fec2311d1e4768e4 (diff) | |
| download | rust-de68aced95ab53bc0f69ff4d6867a03d2dd0f8d7.tar.gz rust-de68aced95ab53bc0f69ff4d6867a03d2dd0f8d7.zip | |
Add current_exe support
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/redox/os.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs index 309201352c4..e007e33258f 100644 --- a/src/libstd/sys/redox/os.rs +++ b/src/libstd/sys/redox/os.rs @@ -113,8 +113,18 @@ impl StdError for JoinPathsError { } pub fn current_exe() -> io::Result<PathBuf> { - use io::ErrorKind; - Err(io::Error::new(ErrorKind::Other, "Not yet implemented on redox")) + use fs::File; + + let mut file = File::open("sys:exe")?; + + let mut path = String::new(); + file.read_to_string(&mut path)?; + + if path.ends_with('\n') { + path.pop(); + } + + Ok(PathBuf::from(path)) } pub struct Env { |
