@@ -41,6 +41,11 @@ pub fn try_into_bstr<'a>(path: impl Into<Cow<'a, Path>>) -> Result<Cow<'a, BStr>
41
41
use std:: os:: unix:: ffi:: OsStringExt ;
42
42
path. into_os_string ( ) . into_vec ( ) . into ( )
43
43
} ;
44
+ #[ cfg( target_os = "wasi" ) ]
45
+ let p: BString = {
46
+ use std:: os:: wasi:: ffi:: OsStringExt ;
47
+ path. into_os_string ( ) . into_vec ( ) . into ( )
48
+ } ;
44
49
#[ cfg( not( unix) ) ]
45
50
let p: BString = path. into_os_string ( ) . into_string ( ) . map_err ( |_| Utf8Error ) ?. into ( ) ;
46
51
p
@@ -51,6 +56,11 @@ pub fn try_into_bstr<'a>(path: impl Into<Cow<'a, Path>>) -> Result<Cow<'a, BStr>
51
56
use std:: os:: unix:: ffi:: OsStrExt ;
52
57
path. as_os_str ( ) . as_bytes ( ) . into ( )
53
58
} ;
59
+ #[ cfg( target_os = "wasi" ) ]
60
+ let p: & BStr = {
61
+ use std:: os:: wasi:: ffi:: OsStrExt ;
62
+ path. as_os_str ( ) . as_bytes ( ) . into ( )
63
+ } ;
54
64
#[ cfg( not( unix) ) ]
55
65
let p: & BStr = path. to_str ( ) . ok_or ( Utf8Error ) ?. as_bytes ( ) . into ( ) ;
56
66
p
@@ -75,6 +85,11 @@ pub fn try_from_byte_slice(input: &[u8]) -> Result<&Path, Utf8Error> {
75
85
use std:: os:: unix:: ffi:: OsStrExt ;
76
86
OsStr :: from_bytes ( input) . as_ref ( )
77
87
} ;
88
+ #[ cfg( target_os = "wasi" ) ]
89
+ let p = {
90
+ use std:: os:: wasi:: ffi:: OsStrExt ;
91
+ OsStr :: from_bytes ( input) . as_ref ( )
92
+ } ;
78
93
#[ cfg( not( unix) ) ]
79
94
let p = Path :: new ( std:: str:: from_utf8 ( input) . map_err ( |_| Utf8Error ) ?) ;
80
95
Ok ( p)
@@ -102,6 +117,11 @@ pub fn try_from_bstring(input: impl Into<BString>) -> Result<PathBuf, Utf8Error>
102
117
use std:: os:: unix:: ffi:: OsStringExt ;
103
118
std:: ffi:: OsString :: from_vec ( input. into ( ) ) . into ( )
104
119
} ;
120
+ #[ cfg( target_os = "wasi" ) ]
121
+ let p = {
122
+ use std:: os:: wasi:: ffi:: OsStringExt ;
123
+ std:: ffi:: OsString :: from_vec ( input. into ( ) ) . into ( )
124
+ } ;
105
125
#[ cfg( not( unix) ) ]
106
126
let p = {
107
127
use bstr:: ByteVec ;
0 commit comments