1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
mod dir;
mod dir_entry;
mod file;
mod read_dir;
pub use dir::*;
pub use dir_entry::*;
pub use file::*;
pub use read_dir::*;
#[cfg(not(target_os = "wasi"))]
pub use cap_primitives::fs::{DirBuilder, FileType, Metadata, OpenOptions, Permissions};
#[cfg(target_os = "wasi")]
pub use async_std::fs::{DirBuilder, FileType, Metadata, OpenOptions, Permissions};
#[inline]
pub(crate) unsafe fn as_sync(
async_file: &async_std::fs::File,
) -> std::mem::ManuallyDrop<std::fs::File> {
_as_sync(async_file)
}
#[cfg(not(windows))]
unsafe fn _as_sync(async_file: &async_std::fs::File) -> std::mem::ManuallyDrop<std::fs::File> {
use std::os::unix::io::{AsRawFd, FromRawFd};
std::mem::ManuallyDrop::new(std::fs::File::from_raw_fd(async_file.as_raw_fd()))
}
#[cfg(windows)]
unsafe fn _as_sync(async_file: &async_std::fs::File) -> std::mem::ManuallyDrop<std::fs::File> {
use std::os::windows::io::{AsRawHandle, FromRawHandle};
std::mem::ManuallyDrop::new(std::fs::File::from_raw_handle(async_file.as_raw_handle()))
}
#[inline]
pub(crate) fn into_sync(async_file: async_std::fs::File) -> std::fs::File {
_into_sync(async_file)
}
#[cfg(not(windows))]
fn _into_sync(async_file: async_std::fs::File) -> std::fs::File {
use std::os::unix::io::{AsRawFd, FromRawFd};
unsafe { std::fs::File::from_raw_fd(async_file.as_raw_fd()) }
}
#[cfg(windows)]
fn _into_sync(async_file: async_std::fs::File) -> std::fs::File {
use std::os::windows::io::{AsRawHandle, FromRawHandle};
unsafe { std::fs::File::from_raw_handle(async_file.as_raw_handle()) }
}