@@ -11,10 +11,9 @@ use crate::sys::{unsupported, unsupported_err};
11
11
#[ expect( dead_code) ]
12
12
#[ path = "unsupported.rs" ]
13
13
mod unsupported_fs;
14
-
15
14
pub use unsupported_fs:: {
16
- DirBuilder , FilePermissions , FileTimes , ReadDir , canonicalize, link, remove_dir_all, rename,
17
- rmdir , set_perm , symlink , unlink,
15
+ DirBuilder , FileTimes , canonicalize, link, readlink , remove_dir_all, rename, rmdir , symlink ,
16
+ unlink,
18
17
} ;
19
18
20
19
#[ derive( Debug ) ]
@@ -30,6 +29,8 @@ pub enum FileAttr {
30
29
File { size : u64 } ,
31
30
}
32
31
32
+ pub struct ReadDir ( !) ;
33
+
33
34
pub struct DirEntry {
34
35
path : PathBuf ,
35
36
}
@@ -44,6 +45,9 @@ pub struct OpenOptions {
44
45
create_new : bool ,
45
46
}
46
47
48
+ #[ derive( Clone , PartialEq , Eq , Debug ) ]
49
+ pub struct FilePermissions { }
50
+
47
51
#[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug ) ]
48
52
pub struct FileType {
49
53
is_dir : bool ,
@@ -108,6 +112,16 @@ impl FileAttr {
108
112
}
109
113
}
110
114
115
+ impl FilePermissions {
116
+ pub fn readonly ( & self ) -> bool {
117
+ false
118
+ }
119
+
120
+ pub fn set_readonly ( & mut self , _readonly : bool ) {
121
+ panic ! ( "Perimissions do not exist" )
122
+ }
123
+ }
124
+
111
125
impl FileType {
112
126
pub fn is_dir ( & self ) -> bool {
113
127
self . is_dir
@@ -123,6 +137,38 @@ impl FileType {
123
137
}
124
138
}
125
139
140
+ impl fmt:: Debug for ReadDir {
141
+ fn fmt ( & self , _f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
142
+ self . 0
143
+ }
144
+ }
145
+
146
+ impl Iterator for ReadDir {
147
+ type Item = io:: Result < DirEntry > ;
148
+
149
+ fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
150
+ self . 0
151
+ }
152
+ }
153
+
154
+ impl DirEntry {
155
+ pub fn path ( & self ) -> PathBuf {
156
+ self . path . clone ( )
157
+ }
158
+
159
+ pub fn file_name ( & self ) -> OsString {
160
+ self . path . file_name ( ) . unwrap_or_default ( ) . into ( )
161
+ }
162
+
163
+ pub fn metadata ( & self ) -> io:: Result < FileAttr > {
164
+ stat ( & self . path )
165
+ }
166
+
167
+ pub fn file_type ( & self ) -> io:: Result < FileType > {
168
+ Ok ( self . metadata ( ) ?. file_type ( ) )
169
+ }
170
+ }
171
+
126
172
impl OpenOptions {
127
173
pub fn new ( ) -> OpenOptions {
128
174
OpenOptions {
@@ -436,6 +482,21 @@ impl Drop for File {
436
482
}
437
483
}
438
484
485
+ pub fn readdir ( _p : & Path ) -> io:: Result < ReadDir > {
486
+ // While there *is* a userspace function for reading file directories,
487
+ // the necessary implementation cannot currently be done cleanly, as
488
+ // VEXos does not expose directory length to user programs.
489
+ //
490
+ // This means that we would need to create a large fixed-length buffer
491
+ // and hope that the folder's contents didn't exceed that buffer's length,
492
+ // which obviously isn't behavior we want to rely on in the standard library.
493
+ unsupported ( )
494
+ }
495
+
496
+ pub fn set_perm ( _p : & Path , _perm : FilePermissions ) -> io:: Result < ( ) > {
497
+ unsupported ( )
498
+ }
499
+
439
500
pub fn exists ( path : & Path ) -> io:: Result < bool > {
440
501
run_path_with_cstr ( path, & |path| Ok ( unsafe { vex_sdk:: vexFileStatus ( path. as_ptr ( ) ) } != 0 ) )
441
502
}
0 commit comments