There was an error while loading. Please reload this page.
1 parent 3a1caa1 commit 689c8b5Copy full SHA for 689c8b5
1 file changed
crates/host_env/src/os.rs
@@ -519,13 +519,14 @@ pub fn set_errno(value: i32) {
519
#[cfg(not(any(unix, windows, target_os = "wasi")))]
520
pub fn set_errno(_value: i32) {}
521
522
-#[cfg(unix)]
+// WASIp1, like Unix, provides byte-preserving OsStr conversions.
523
+#[cfg(any(unix, all(target_os = "wasi", not(target_env = "p2"))))]
524
pub fn bytes_as_os_str(b: &[u8]) -> Result<&std::ffi::OsStr, Utf8Error> {
- use std::os::unix::ffi::OsStrExt;
525
+ use self::ffi::OsStrExt;
526
Ok(std::ffi::OsStr::from_bytes(b))
527
}
528
-#[cfg(not(unix))]
529
+#[cfg(not(any(unix, all(target_os = "wasi", not(target_env = "p2")))))]
530
531
Ok(core::str::from_utf8(b)?.as_ref())
532
0 commit comments