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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
use crate;
use crateRemoveDir;
use crateget_os_path;
use Result;
use Path;
/// Opens a file asynchronously with the specified open options.
///
/// This function is a wrapper around the [`File::open`] method, which opens a file
/// located at `path` with the provided `open_options`.
///
/// # Example
///
/// ```rust
/// use orengine::fs::{File, OpenOptions, open_file};
///
/// # async fn foo() -> std::io::Result<()> {
/// let options = OpenOptions::new().read(true).write(true);
/// let file = open_file("example.txt", &options).await?;
/// # Ok(())
/// # }
/// ```
///
/// # Errors
///
/// This function will return an `Err` if the file cannot be opened due to I/O errors
/// (e.g., file not found, permission denied).
pub async
/// Creates a new directory at the specified path.
///
/// This function asynchronously creates a single directory at `path`
/// unlike [`create_dir_all`] which creates a full directory tree.
///
/// If the directory already exists, the function does nothing.
///
/// # Example
///
/// ```rust
/// use std::path::Path;
/// use orengine::fs::create_dir;
///
/// # async fn foo() -> std::io::Result<()> {
/// create_dir("new_directory").await?;
/// assert!(Path::new("new_directory").exists());
/// # Ok(())
/// # }
/// ```
///
/// # Errors
///
/// This function will return an `Err` if the directory cannot be created due to I/O errors
/// (e.g., permission denied, path does not exist).
pub async
/// Recursively creates all directories in the given path.
///
/// This function creates the entire directory tree if it doesn't exist,
/// unlike [`create_dir`] which only creates a single directory.
///
/// # Example
///
/// ```rust
/// use orengine::fs::create_dir_all;
///
/// # async fn foo() -> std::io::Result<()> {
/// create_dir_all("parent/child/grandchild").await?;
/// # Ok(())
/// # }
/// ```
///
/// # Errors
///
/// This function will return an `Err` if any directory in the path cannot be created
/// due to I/O errors.
pub async
/// Removes the directory at the specified path.
///
/// This function asynchronously deletes a directory. The directory must be empty,
/// otherwise an error will be returned.
///
/// # Example
///
/// ```rust
/// use std::path::Path;
/// use orengine::fs::remove_dir;
///
/// # async fn foo() -> std::io::Result<()> {
/// remove_dir("empty_directory").await?;
/// assert!(!Path::new("empty_directory").exists());
/// # Ok(())
/// # }
/// ```
///
/// # Errors
///
/// This function will return an `Err` if the directory is not empty or cannot be deleted
/// due to I/O errors.
pub async
/// Removes the file at the specified path.
///
/// This function asynchronously deletes a file at `path`. If the file does not exist,
/// an error will be returned.
///
/// # Example
///
/// ```rust
/// use std::path::Path;
/// use orengine::fs::remove_file;
///
/// # async fn foo() -> std::io::Result<()> {
/// remove_file("example.txt").await?;
/// assert!(!Path::new("example.txt").exists());
/// # Ok(())
/// # }
/// ```
///
/// # Errors
///
/// This function will return an `Err` if the file cannot be deleted due to I/O errors
/// (e.g., permission denied, file not found).
pub async
/// Renames a file or directory from one path to another.
///
/// This function asynchronously renames `old_path` to `new_path`. Both paths must refer
/// to valid file or directory names.
///
/// # Example
///
/// ```rust
/// use std::path::Path;
/// use orengine::fs::rename;
///
/// # async fn foo() -> std::io::Result<()> {
/// rename("old_name.txt", "new_name.txt").await?;
/// assert!(!Path::new("old_name.txt").exists());
/// assert!(Path::new("new_name.txt").exists());
/// # Ok(())
/// # }
/// ```
///
/// # Errors
///
/// This function will return an `Err` if the rename operation fails due to I/O errors
/// (e.g., permission denied, file not found).
pub async
/// we need to check only [`remove_dir`], because all others functions was already tested in
/// [`file`](crate::fs::file) or [`dir_builder`](crate::fs::dir_builder).