@@ -8,6 +8,15 @@ use crate::sys::common::small_c_string::run_path_with_cstr;
88use crate :: sys:: time:: SystemTime ;
99use crate :: sys:: { unsupported, unsupported_err} ;
1010
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+
1120#[ derive( Debug ) ]
1221struct FileDesc ( * mut vex_sdk:: FIL ) ;
1322
@@ -21,8 +30,6 @@ pub enum FileAttr {
2130 File { size : u64 } ,
2231}
2332
24- pub struct ReadDir ( !) ;
25-
2633pub struct DirEntry {
2734 path : PathBuf ,
2835}
@@ -37,20 +44,11 @@ pub struct OpenOptions {
3744 create_new : bool ,
3845}
3946
40- #[ derive( Copy , Clone , Debug , Default ) ]
41- pub struct FileTimes { }
42-
43- #[ derive( Clone , PartialEq , Eq , Debug ) ]
44- pub struct FilePermissions { }
45-
4647#[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug ) ]
4748pub struct FileType {
4849 is_dir : bool ,
4950}
5051
51- #[ derive( Debug ) ]
52- pub struct DirBuilder { }
53-
5452impl FileAttr {
5553 /// Creates a FileAttr by getting data from an opened file.
5654 fn from_fd ( fd : * mut vex_sdk:: FIL ) -> io:: Result < Self > {
@@ -110,21 +108,6 @@ impl FileAttr {
110108 }
111109}
112110
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-
128111impl FileType {
129112 pub fn is_dir ( & self ) -> bool {
130113 self . is_dir
@@ -140,38 +123,6 @@ impl FileType {
140123 }
141124}
142125
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-
175126impl OpenOptions {
176127 pub fn new ( ) -> OpenOptions {
177128 OpenOptions {
@@ -474,16 +425,6 @@ impl File {
474425 }
475426}
476427
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-
487428impl fmt:: Debug for File {
488429 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
489430 f. debug_struct ( "File" ) . field ( "fd" , & self . fd . 0 ) . finish ( )
@@ -495,53 +436,10 @@ impl Drop for File {
495436 }
496437}
497438
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-
529439pub fn exists ( path : & Path ) -> io:: Result < bool > {
530440 run_path_with_cstr ( path, & |path| Ok ( unsafe { vex_sdk:: vexFileStatus ( path. as_ptr ( ) ) } != 0 ) )
531441}
532442
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-
545443pub fn stat ( p : & Path ) -> io:: Result < FileAttr > {
546444 FileAttr :: from_path ( p)
547445}
@@ -551,10 +449,6 @@ pub fn lstat(p: &Path) -> io::Result<FileAttr> {
551449 stat ( p)
552450}
553451
554- pub fn canonicalize ( _p : & Path ) -> io:: Result < PathBuf > {
555- unsupported ( )
556- }
557-
558452pub fn copy ( from : & Path , to : & Path ) -> io:: Result < u64 > {
559453 use crate :: fs:: File ;
560454
0 commit comments