We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
error_string
1 parent 60f6cbd commit 32a7684Copy full SHA for 32a7684
src/libstd/sys/wasi/os.rs
@@ -27,8 +27,21 @@ pub fn errno() -> i32 {
27
unsafe { errno as i32 }
28
}
29
30
-pub fn error_string(_errno: i32) -> String {
31
- "operation failed".to_string()
+pub fn error_string(errno: i32) -> String {
+ extern {
32
+ fn strerror_r(errnum: libc::c_int, buf: *mut libc::c_char,
33
+ buflen: libc::size_t) -> libc::c_int;
34
+ }
35
+
36
+ let mut buf = [0 as libc::c_char; 1024];
37
38
+ let p = buf.as_mut_ptr();
39
+ unsafe {
40
+ if strerror_r(errno as libc::c_int, p, buf.len()) < 0 {
41
+ panic!("strerror_r failure");
42
43
+ str::from_utf8(CStr::from_ptr(p).to_bytes()).unwrap().to_owned()
44
45
46
47
pub fn getcwd() -> io::Result<PathBuf> {
0 commit comments