@@ -8,6 +8,15 @@ use crate::sys::common::small_c_string::run_path_with_cstr;
8
8
use crate :: sys:: time:: SystemTime ;
9
9
use crate :: sys:: { unsupported, unsupported_err} ;
10
10
11
+ #[ expect( dead_code) ]
12
+ #[ path = "unsupported.rs" ]
13
+ mod unsupported_fs;
14
+
15
+ pub use unsupported_fs:: {
16
+ DirBuilder , FilePermissions , FileTimes , ReadDir , canonicalize, link, remove_dir_all, rename,
17
+ rmdir, set_perm, symlink, unlink,
18
+ } ;
19
+
11
20
#[ derive( Debug ) ]
12
21
struct FileDesc ( * mut vex_sdk:: FIL ) ;
13
22
@@ -21,8 +30,6 @@ pub enum FileAttr {
21
30
File { size : u64 } ,
22
31
}
23
32
24
- pub struct ReadDir ( !) ;
25
-
26
33
pub struct DirEntry {
27
34
path : PathBuf ,
28
35
}
@@ -37,20 +44,11 @@ pub struct OpenOptions {
37
44
create_new : bool ,
38
45
}
39
46
40
- #[ derive( Copy , Clone , Debug , Default ) ]
41
- pub struct FileTimes { }
42
-
43
- #[ derive( Clone , PartialEq , Eq , Debug ) ]
44
- pub struct FilePermissions { }
45
-
46
47
#[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug ) ]
47
48
pub struct FileType {
48
49
is_dir : bool ,
49
50
}
50
51
51
- #[ derive( Debug ) ]
52
- pub struct DirBuilder { }
53
-
54
52
impl FileAttr {
55
53
/// Creates a FileAttr by getting data from an opened file.
56
54
fn from_fd ( fd : * mut vex_sdk:: FIL ) -> io:: Result < Self > {
@@ -110,21 +108,6 @@ impl FileAttr {
110
108
}
111
109
}
112
110
113
- impl FilePermissions {
114
- pub fn readonly ( & self ) -> bool {
115
- false
116
- }
117
-
118
- pub fn set_readonly ( & mut self , _readonly : bool ) {
119
- panic ! ( "Perimissions do not exist" )
120
- }
121
- }
122
-
123
- impl FileTimes {
124
- pub fn set_accessed ( & mut self , _t : SystemTime ) { }
125
- pub fn set_modified ( & mut self , _t : SystemTime ) { }
126
- }
127
-
128
111
impl FileType {
129
112
pub fn is_dir ( & self ) -> bool {
130
113
self . is_dir
@@ -140,38 +123,6 @@ impl FileType {
140
123
}
141
124
}
142
125
143
- impl fmt:: Debug for ReadDir {
144
- fn fmt ( & self , _f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
145
- self . 0
146
- }
147
- }
148
-
149
- impl Iterator for ReadDir {
150
- type Item = io:: Result < DirEntry > ;
151
-
152
- fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
153
- self . 0
154
- }
155
- }
156
-
157
- impl DirEntry {
158
- pub fn path ( & self ) -> PathBuf {
159
- self . path . clone ( )
160
- }
161
-
162
- pub fn file_name ( & self ) -> OsString {
163
- self . path . file_name ( ) . unwrap_or_default ( ) . into ( )
164
- }
165
-
166
- pub fn metadata ( & self ) -> io:: Result < FileAttr > {
167
- stat ( & self . path )
168
- }
169
-
170
- pub fn file_type ( & self ) -> io:: Result < FileType > {
171
- Ok ( self . metadata ( ) ?. file_type ( ) )
172
- }
173
- }
174
-
175
126
impl OpenOptions {
176
127
pub fn new ( ) -> OpenOptions {
177
128
OpenOptions {
@@ -474,16 +425,6 @@ impl File {
474
425
}
475
426
}
476
427
477
- impl DirBuilder {
478
- pub fn new ( ) -> DirBuilder {
479
- DirBuilder { }
480
- }
481
-
482
- pub fn mkdir ( & self , _p : & Path ) -> io:: Result < ( ) > {
483
- unsupported ( )
484
- }
485
- }
486
-
487
428
impl fmt:: Debug for File {
488
429
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
489
430
f. debug_struct ( "File" ) . field ( "fd" , & self . fd . 0 ) . finish ( )
@@ -495,53 +436,10 @@ impl Drop for File {
495
436
}
496
437
}
497
438
498
- pub fn readdir ( _p : & Path ) -> io:: Result < ReadDir > {
499
- // While there *is* a userspace function for reading file directories,
500
- // the necessary implementation cannot currently be done cleanly, as
501
- // VEXos does not expose directory length to user programs.
502
- //
503
- // This means that we would need to create a large fixed-length buffer
504
- // and hope that the folder's contents didn't exceed that buffer's length,
505
- // which obviously isn't behavior we want to rely on in the standard library.
506
- unsupported ( )
507
- }
508
-
509
- pub fn unlink ( _p : & Path ) -> io:: Result < ( ) > {
510
- unsupported ( )
511
- }
512
-
513
- pub fn rename ( _old : & Path , _new : & Path ) -> io:: Result < ( ) > {
514
- unsupported ( )
515
- }
516
-
517
- pub fn set_perm ( _p : & Path , _perm : FilePermissions ) -> io:: Result < ( ) > {
518
- unsupported ( )
519
- }
520
-
521
- pub fn rmdir ( _p : & Path ) -> io:: Result < ( ) > {
522
- unsupported ( )
523
- }
524
-
525
- pub fn remove_dir_all ( _path : & Path ) -> io:: Result < ( ) > {
526
- unsupported ( )
527
- }
528
-
529
439
pub fn exists ( path : & Path ) -> io:: Result < bool > {
530
440
run_path_with_cstr ( path, & |path| Ok ( unsafe { vex_sdk:: vexFileStatus ( path. as_ptr ( ) ) } != 0 ) )
531
441
}
532
442
533
- pub fn readlink ( _p : & Path ) -> io:: Result < PathBuf > {
534
- unsupported ( )
535
- }
536
-
537
- pub fn symlink ( _original : & Path , _link : & Path ) -> io:: Result < ( ) > {
538
- unsupported ( )
539
- }
540
-
541
- pub fn link ( _src : & Path , _dst : & Path ) -> io:: Result < ( ) > {
542
- unsupported ( )
543
- }
544
-
545
443
pub fn stat ( p : & Path ) -> io:: Result < FileAttr > {
546
444
FileAttr :: from_path ( p)
547
445
}
@@ -551,10 +449,6 @@ pub fn lstat(p: &Path) -> io::Result<FileAttr> {
551
449
stat ( p)
552
450
}
553
451
554
- pub fn canonicalize ( _p : & Path ) -> io:: Result < PathBuf > {
555
- unsupported ( )
556
- }
557
-
558
452
pub fn copy ( from : & Path , to : & Path ) -> io:: Result < u64 > {
559
453
use crate :: fs:: File ;
560
454
0 commit comments