Skip to content

Commit de68ace

Browse files
committed
Add current_exe support
1 parent 18bf054 commit de68ace

File tree

1 file changed

+12
-2
lines changed
  • src/libstd/sys/redox

1 file changed

+12
-2
lines changed

src/libstd/sys/redox/os.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,18 @@ impl StdError for JoinPathsError {
113113
}
114114

115115
pub fn current_exe() -> io::Result<PathBuf> {
116-
use io::ErrorKind;
117-
Err(io::Error::new(ErrorKind::Other, "Not yet implemented on redox"))
116+
use fs::File;
117+
118+
let mut file = File::open("sys:exe")?;
119+
120+
let mut path = String::new();
121+
file.read_to_string(&mut path)?;
122+
123+
if path.ends_with('\n') {
124+
path.pop();
125+
}
126+
127+
Ok(PathBuf::from(path))
118128
}
119129

120130
pub struct Env {

0 commit comments

Comments
 (0)