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
85
mod mmap;
#[cfg(unix)]
mod file_slice;
#[cfg(unix)]
mod async_file;
mod bounded;
#[cfg(unix)]
pub use self::async_file::AsyncFile;
#[cfg(unix)]
pub use self::file_slice::AsyncFileSlice;
pub use self::bounded::BoundedFileSink;
pub use self::bounded::BoundedFileOption;
pub use self::bounded::BoundedFileSinkError;
pub use self::mmap::MemoryMappedFile;
pub use self::mmap::MemoryMappedMutFile;
#[cfg(feature = "asyncstd")]
pub use async_std::fs::*;
#[cfg(feature = "tokio2")]
pub use tokio::fs::*;
pub mod util {
use std::io::Error as IoError;
use std::path::Path;
use super::File;
use super::OpenOptions;
pub async fn create_dir_all<P: AsRef<Path>>(path: P) -> Result<(), IoError> {
super::create_dir_all(path.as_ref()).await
}
pub async fn create<P>(path: P) -> Result<File, IoError>
where
P: AsRef<Path>,
{
File::create(path.as_ref()).await
}
pub async fn open<P>(path: P) -> Result<File, IoError>
where
P: AsRef<Path>,
{
let file_path = path.as_ref();
File::open(file_path).await
}
pub async fn open_read_write<P>(path: P) -> Result<File, IoError>
where
P: AsRef<Path>,
{
let file_path = path.as_ref();
let mut option = OpenOptions::new();
option.read(true).write(true).create(true).append(false);
option.open(file_path).await
}
pub async fn open_read_append<P>(path: P) -> Result<File, IoError>
where
P: AsRef<Path>,
{
let file_path = path.as_ref();
let mut option = OpenOptions::new();
option.read(true).create(true).append(true);
option.open(file_path).await
}
}