Skip to content

Commit 9963bf9

Browse files
committed
Move filepath behind feature gate
1 parent d6d689d commit 9963bf9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

vm/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ openssl = { version = "0.10.32", features = ["vendored"], optional = true }
123123
openssl-sys = { version = "0.9", optional = true }
124124
openssl-probe = { version = "0.1", optional = true }
125125
which = "4.0"
126-
filepath = "0.1.1"
127126

128127
[target.'cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))'.dependencies]
129128
num_cpus = "1"
@@ -148,5 +147,8 @@ features = [
148147
[target.'cfg(target_arch = "wasm32")'.dependencies]
149148
wasm-bindgen = "0.2"
150149

150+
[target.'cfg(any(target_os = "linux", target_os = "macos", windows))'.dependencies]
151+
filepath = "0.1.1"
152+
151153
[build-dependencies]
152154
itertools = "0.9"

vm/src/stdlib/os.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::time::{Duration, SystemTime};
77
use std::{env, fs};
88

99
use crossbeam_utils::atomic::AtomicCell;
10-
#[cfg(not(target_os = "wasi"))]
10+
#[cfg(any(target_os = "linux", target_os = "macos", windows))]
1111
use filepath::FilePath;
1212
use num_bigint::BigInt;
1313

@@ -165,14 +165,12 @@ fn make_path<'a>(
165165
dir_fd: &DirFd,
166166
) -> PyResult<std::borrow::Cow<'a, ffi::OsStr>> {
167167
let path = &path.path;
168-
if dir_fd.0.is_none() | path.is_absolute() {
169-
return Ok(std::borrow::Cow::Borrowed(path.as_os_str().into()));
168+
if dir_fd.0.is_none() || path.is_absolute() {
169+
return Ok(path.as_os_str().into());
170170
}
171171

172172
cfg_if::cfg_if! {
173-
if #[cfg(target_os = "wasi")] {
174-
return Err(vm.new_os_error("dir_fd not supported on wasi yet".to_owned()));
175-
} else {
173+
if #[cfg(any(target_os = "linux", target_os = "macos", windows))] {
176174
let dir_path = match rust_file(dir_fd.0.unwrap().into()).path() {
177175
Ok(dir_path) => dir_path,
178176
Err(_) => {
@@ -181,6 +179,8 @@ fn make_path<'a>(
181179
};
182180
let p: PathBuf = vec![dir_path, path.to_path_buf()].iter().collect();
183181
Ok(p.into_os_string().into())
182+
} else {
183+
return Err(vm.new_os_error("dir_fd not supported on wasi yet".to_owned()));
184184
}
185185
}
186186
}

0 commit comments

Comments
 (0)