Move filepath behind feature gate

This commit is contained in:
Dean Li
2021-03-16 20:14:31 +08:00
parent d6d689dc1f
commit 9963bf9fe4
2 changed files with 9 additions and 7 deletions

View File

@@ -123,7 +123,6 @@ openssl = { version = "0.10.32", features = ["vendored"], optional = true }
openssl-sys = { version = "0.9", optional = true }
openssl-probe = { version = "0.1", optional = true }
which = "4.0"
filepath = "0.1.1"
[target.'cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))'.dependencies]
num_cpus = "1"
@@ -148,5 +147,8 @@ features = [
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2"
[target.'cfg(any(target_os = "linux", target_os = "macos", windows))'.dependencies]
filepath = "0.1.1"
[build-dependencies]
itertools = "0.9"

View File

@@ -7,7 +7,7 @@ use std::time::{Duration, SystemTime};
use std::{env, fs};
use crossbeam_utils::atomic::AtomicCell;
#[cfg(not(target_os = "wasi"))]
#[cfg(any(target_os = "linux", target_os = "macos", windows))]
use filepath::FilePath;
use num_bigint::BigInt;
@@ -165,14 +165,12 @@ fn make_path<'a>(
dir_fd: &DirFd,
) -> PyResult<std::borrow::Cow<'a, ffi::OsStr>> {
let path = &path.path;
if dir_fd.0.is_none() | path.is_absolute() {
return Ok(std::borrow::Cow::Borrowed(path.as_os_str().into()));
if dir_fd.0.is_none() || path.is_absolute() {
return Ok(path.as_os_str().into());
}
cfg_if::cfg_if! {
if #[cfg(target_os = "wasi")] {
return Err(vm.new_os_error("dir_fd not supported on wasi yet".to_owned()));
} else {
if #[cfg(any(target_os = "linux", target_os = "macos", windows))] {
let dir_path = match rust_file(dir_fd.0.unwrap().into()).path() {
Ok(dir_path) => dir_path,
Err(_) => {
@@ -181,6 +179,8 @@ fn make_path<'a>(
};
let p: PathBuf = vec![dir_path, path.to_path_buf()].iter().collect();
Ok(p.into_os_string().into())
} else {
return Err(vm.new_os_error("dir_fd not supported on wasi yet".to_owned()));
}
}
}