From de68aced95ab53bc0f69ff4d6867a03d2dd0f8d7 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 14 Nov 2016 19:08:48 -0700 Subject: Add current_exe support --- src/libstd/sys/redox/os.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/libstd/sys') 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 { - 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 { -- cgit 1.4.1-3-g733a5