Skip to content

Commit 58d804b

Browse files
committed
More WASI support.
1 parent 5b55f55 commit 58d804b

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

cap-primitives/src/posish/fs/c_str.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use std::{ffi::CString, io, os::unix::ffi::OsStrExt, path::Path};
1+
#[cfg(unix)]
2+
use std::os::unix::ffi::OsStrExt;
3+
#[cfg(target_os = "wasi")]
4+
use std::os::wasi::ffi::OsStrExt;
5+
use std::{ffi::CString, io, path::Path};
26

37
#[allow(dead_code)]
48
pub(crate) fn c_str(path: &Path) -> io::Result<CString> {

cap-primitives/src/posish/fs/dir_entry_inner.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use crate::fs::{FileType, FileTypeExt, Metadata, OpenOptions, ReadDir, ReadDirInner};
22
use posish::fs::Entry;
33
#[cfg(unix)]
4+
use std::os::unix::ffi::OsStrExt;
5+
#[cfg(unix)]
46
use std::os::unix::fs::MetadataExt;
57
#[cfg(target_os = "wasi")]
6-
use std::os::wasi::fs::MetadataExt;
8+
use std::os::wasi::{ffi::OsStrExt, fs::MetadataExt};
79
use std::{
810
ffi::{OsStr, OsString},
911
fmt, fs, io,
10-
os::unix::ffi::OsStrExt,
1112
};
1213

1314
pub(crate) struct DirEntryInner {

cap-primitives/src/posish/fs/dir_utils.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
use crate::fs::OpenOptions;
22
use posish::fs::OFlags;
3+
#[cfg(unix)]
4+
use std::os::unix::{ffi::OsStrExt, fs::OpenOptionsExt};
5+
#[cfg(target_os = "wasi")]
6+
use std::os::wasi::{ffi::OsStrExt, fs::OpenOptionsExt};
37
use std::{
48
ffi::OsStr,
59
fs, io,
610
ops::Deref,
7-
os::unix::{ffi::OsStrExt, fs::OpenOptionsExt},
811
path::{Component, Path},
912
};
1013
#[cfg(racy_asserts)]

cap-primitives/src/posish/fs/read_dir_inner.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ use crate::fs::{
44
ReadDir,
55
};
66
use posish::fs::Dir;
7+
#[cfg(unix)]
8+
use std::os::unix::{
9+
ffi::OsStrExt,
10+
io::{AsRawFd, FromRawFd},
11+
};
12+
#[cfg(target_os = "wasi")]
13+
use std::os::wasi::{
14+
ffi::OsStrExt,
15+
io::{AsRawFd, FromRawFd},
16+
};
717
use std::{
818
ffi::OsStr,
919
fmt, fs, io,
1020
mem::ManuallyDrop,
11-
os::unix::{
12-
ffi::OsStrExt,
13-
io::{AsRawFd, FromRawFd},
14-
},
1521
path::{Component, Path},
1622
sync::Arc,
1723
};

0 commit comments

Comments
 (0)