]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/unsupported/fs.rs
Support setting file accessed/modified timestamps
[rust.git] / library / std / src / sys / unsupported / fs.rs
1 use crate::ffi::OsString;
2 use crate::fmt;
3 use crate::hash::{Hash, Hasher};
4 use crate::io::{self, IoSlice, IoSliceMut, ReadBuf, SeekFrom};
5 use crate::path::{Path, PathBuf};
6 use crate::sys::time::SystemTime;
7 use crate::sys::unsupported;
8
9 pub struct File(!);
10
11 pub struct FileAttr(!);
12
13 pub struct ReadDir(!);
14
15 pub struct DirEntry(!);
16
17 #[derive(Clone, Debug)]
18 pub struct OpenOptions {}
19
20 #[derive(Copy, Clone, Debug, Default)]
21 pub struct FileTimes {}
22
23 pub struct FilePermissions(!);
24
25 pub struct FileType(!);
26
27 #[derive(Debug)]
28 pub struct DirBuilder {}
29
30 impl FileAttr {
31     pub fn size(&self) -> u64 {
32         self.0
33     }
34
35     pub fn perm(&self) -> FilePermissions {
36         self.0
37     }
38
39     pub fn file_type(&self) -> FileType {
40         self.0
41     }
42
43     pub fn modified(&self) -> io::Result<SystemTime> {
44         self.0
45     }
46
47     pub fn accessed(&self) -> io::Result<SystemTime> {
48         self.0
49     }
50
51     pub fn created(&self) -> io::Result<SystemTime> {
52         self.0
53     }
54 }
55
56 impl Clone for FileAttr {
57     fn clone(&self) -> FileAttr {
58         self.0
59     }
60 }
61
62 impl FilePermissions {
63     pub fn readonly(&self) -> bool {
64         self.0
65     }
66
67     pub fn set_readonly(&mut self, _readonly: bool) {
68         self.0
69     }
70 }
71
72 impl Clone for FilePermissions {
73     fn clone(&self) -> FilePermissions {
74         self.0
75     }
76 }
77
78 impl PartialEq for FilePermissions {
79     fn eq(&self, _other: &FilePermissions) -> bool {
80         self.0
81     }
82 }
83
84 impl Eq for FilePermissions {}
85
86 impl fmt::Debug for FilePermissions {
87     fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
88         self.0
89     }
90 }
91
92 impl FileTimes {
93     pub fn set_accessed(&mut self, _t: SystemTime) {}
94     pub fn set_modified(&mut self, _t: SystemTime) {}
95 }
96
97 impl FileType {
98     pub fn is_dir(&self) -> bool {
99         self.0
100     }
101
102     pub fn is_file(&self) -> bool {
103         self.0
104     }
105
106     pub fn is_symlink(&self) -> bool {
107         self.0
108     }
109 }
110
111 impl Clone for FileType {
112     fn clone(&self) -> FileType {
113         self.0
114     }
115 }
116
117 impl Copy for FileType {}
118
119 impl PartialEq for FileType {
120     fn eq(&self, _other: &FileType) -> bool {
121         self.0
122     }
123 }
124
125 impl Eq for FileType {}
126
127 impl Hash for FileType {
128     fn hash<H: Hasher>(&self, _h: &mut H) {
129         self.0
130     }
131 }
132
133 impl fmt::Debug for FileType {
134     fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
135         self.0
136     }
137 }
138
139 impl fmt::Debug for ReadDir {
140     fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
141         self.0
142     }
143 }
144
145 impl Iterator for ReadDir {
146     type Item = io::Result<DirEntry>;
147
148     fn next(&mut self) -> Option<io::Result<DirEntry>> {
149         self.0
150     }
151 }
152
153 impl DirEntry {
154     pub fn path(&self) -> PathBuf {
155         self.0
156     }
157
158     pub fn file_name(&self) -> OsString {
159         self.0
160     }
161
162     pub fn metadata(&self) -> io::Result<FileAttr> {
163         self.0
164     }
165
166     pub fn file_type(&self) -> io::Result<FileType> {
167         self.0
168     }
169 }
170
171 impl OpenOptions {
172     pub fn new() -> OpenOptions {
173         OpenOptions {}
174     }
175
176     pub fn read(&mut self, _read: bool) {}
177     pub fn write(&mut self, _write: bool) {}
178     pub fn append(&mut self, _append: bool) {}
179     pub fn truncate(&mut self, _truncate: bool) {}
180     pub fn create(&mut self, _create: bool) {}
181     pub fn create_new(&mut self, _create_new: bool) {}
182 }
183
184 impl File {
185     pub fn open(_path: &Path, _opts: &OpenOptions) -> io::Result<File> {
186         unsupported()
187     }
188
189     pub fn file_attr(&self) -> io::Result<FileAttr> {
190         self.0
191     }
192
193     pub fn fsync(&self) -> io::Result<()> {
194         self.0
195     }
196
197     pub fn datasync(&self) -> io::Result<()> {
198         self.0
199     }
200
201     pub fn truncate(&self, _size: u64) -> io::Result<()> {
202         self.0
203     }
204
205     pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {
206         self.0
207     }
208
209     pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
210         self.0
211     }
212
213     pub fn is_read_vectored(&self) -> bool {
214         self.0
215     }
216
217     pub fn read_buf(&self, _buf: &mut ReadBuf<'_>) -> io::Result<()> {
218         self.0
219     }
220
221     pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
222         self.0
223     }
224
225     pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result<usize> {
226         self.0
227     }
228
229     pub fn is_write_vectored(&self) -> bool {
230         self.0
231     }
232
233     pub fn flush(&self) -> io::Result<()> {
234         self.0
235     }
236
237     pub fn seek(&self, _pos: SeekFrom) -> io::Result<u64> {
238         self.0
239     }
240
241     pub fn duplicate(&self) -> io::Result<File> {
242         self.0
243     }
244
245     pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> {
246         self.0
247     }
248
249     pub fn set_times(&self, _times: FileTimes) -> io::Result<()> {
250         self.0
251     }
252 }
253
254 impl DirBuilder {
255     pub fn new() -> DirBuilder {
256         DirBuilder {}
257     }
258
259     pub fn mkdir(&self, _p: &Path) -> io::Result<()> {
260         unsupported()
261     }
262 }
263
264 impl fmt::Debug for File {
265     fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
266         self.0
267     }
268 }
269
270 pub fn readdir(_p: &Path) -> io::Result<ReadDir> {
271     unsupported()
272 }
273
274 pub fn unlink(_p: &Path) -> io::Result<()> {
275     unsupported()
276 }
277
278 pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> {
279     unsupported()
280 }
281
282 pub fn set_perm(_p: &Path, perm: FilePermissions) -> io::Result<()> {
283     match perm.0 {}
284 }
285
286 pub fn rmdir(_p: &Path) -> io::Result<()> {
287     unsupported()
288 }
289
290 pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
291     unsupported()
292 }
293
294 pub fn try_exists(_path: &Path) -> io::Result<bool> {
295     unsupported()
296 }
297
298 pub fn readlink(_p: &Path) -> io::Result<PathBuf> {
299     unsupported()
300 }
301
302 pub fn symlink(_original: &Path, _link: &Path) -> io::Result<()> {
303     unsupported()
304 }
305
306 pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> {
307     unsupported()
308 }
309
310 pub fn stat(_p: &Path) -> io::Result<FileAttr> {
311     unsupported()
312 }
313
314 pub fn lstat(_p: &Path) -> io::Result<FileAttr> {
315     unsupported()
316 }
317
318 pub fn canonicalize(_p: &Path) -> io::Result<PathBuf> {
319     unsupported()
320 }
321
322 pub fn copy(_from: &Path, _to: &Path) -> io::Result<u64> {
323     unsupported()
324 }