@@ -11,10 +11,9 @@ use crate::sys::{unsupported, unsupported_err};
1111#[ expect( dead_code) ]  
1212#[ path = "unsupported.rs" ]  
1313mod  unsupported_fs; 
14- 
1514pub  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, 
1817} ; 
1918
2019#[ derive( Debug ) ]  
@@ -30,6 +29,8 @@ pub enum FileAttr {
3029    File  {  size :  u64  } , 
3130} 
3231
32+ pub  struct  ReadDir ( !) ; 
33+ 
3334pub  struct  DirEntry  { 
3435    path :  PathBuf , 
3536} 
@@ -44,6 +45,9 @@ pub struct OpenOptions {
4445    create_new :  bool , 
4546} 
4647
48+ #[ derive( Clone ,  PartialEq ,  Eq ,  Debug ) ]  
49+ pub  struct  FilePermissions  { } 
50+ 
4751#[ derive( Clone ,  Copy ,  PartialEq ,  Eq ,  Hash ,  Debug ) ]  
4852pub  struct  FileType  { 
4953    is_dir :  bool , 
@@ -108,6 +112,16 @@ impl FileAttr {
108112    } 
109113} 
110114
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+ 
111125impl  FileType  { 
112126    pub  fn  is_dir ( & self )  -> bool  { 
113127        self . is_dir 
@@ -123,6 +137,38 @@ impl FileType {
123137    } 
124138} 
125139
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+ 
126172impl  OpenOptions  { 
127173    pub  fn  new ( )  -> OpenOptions  { 
128174        OpenOptions  { 
@@ -436,6 +482,21 @@ impl Drop for File {
436482    } 
437483} 
438484
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+ 
439500pub  fn  exists ( path :  & Path )  -> io:: Result < bool >  { 
440501    run_path_with_cstr ( path,  & |path| Ok ( unsafe  {  vex_sdk:: vexFileStatus ( path. as_ptr ( ) )  }  != 0 ) ) 
441502} 
0 commit comments