@@ -13,7 +13,6 @@ pub struct File {
13
13
fd : FileDesc ,
14
14
}
15
15
16
- //TODO: We may be able to get some of this info
17
16
#[ derive( Clone ) ]
18
17
pub struct FileAttr {
19
18
size : u64 ,
@@ -72,7 +71,6 @@ impl FileAttr {
72
71
73
72
let file_type = unsafe { vex_sdk:: vexFileStatus ( c_path. as_ptr ( ) ) } ;
74
73
let is_dir = file_type == 3 ;
75
- println ! ( "{is_dir}" ) ;
76
74
77
75
// We can't get the size if its a directory because we cant open it as a file
78
76
if is_dir {
@@ -342,7 +340,7 @@ impl File {
342
340
map_fresult ( vex_sdk:: vexFileSeek ( self . fd . 0 , try_convert_offset ( offset) ?, SEEK_SET ) ) ?
343
341
} ,
344
342
345
- // The VEX SDK does not allow seeking with negative offsets.
343
+ // vexOS does not allow seeking with negative offsets.
346
344
// That means we need to calculate the offset from the start for both of these.
347
345
SeekFrom :: End ( offset) => unsafe {
348
346
// If our offset is positive, everything is easy
@@ -429,52 +427,15 @@ impl Drop for File {
429
427
}
430
428
}
431
429
432
- pub fn readdir ( p : & Path ) -> io:: Result < ReadDir > {
433
- // getting directory entries does not work with trailing slashes
434
- let p = Path :: new (
435
- p. to_str ( )
436
- . ok_or ( io:: Error :: new (
437
- io:: ErrorKind :: InvalidInput ,
438
- "Path contained invalid characters" ,
439
- ) ) ?
440
- . trim_end_matches ( "/" ) ,
441
- ) ;
442
-
443
- if !stat ( p) ?. file_type ( ) . is_dir ( ) {
444
- return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput , "Given directory was not a path" ) ) ;
445
- }
446
-
447
- let path = CString :: new ( p. as_os_str ( ) . as_encoded_bytes ( ) )
448
- . map_err ( |_| io:: Error :: new ( io:: ErrorKind :: InvalidInput , "Path contained a null byte" ) ) ?;
449
-
450
- //TODO: Figure out if there is any way to check the number of entries in a directory/the needed length
451
- let mut filenames_buffer = [ 0u8 ; 1000 ] ;
452
- unsafe {
453
- vex_sdk:: vexFileDirectoryGet (
454
- path. as_ptr ( ) ,
455
- filenames_buffer. as_mut_ptr ( ) . cast ( ) ,
456
- filenames_buffer. len ( ) as _ ,
457
- ) ;
458
- }
459
- let filenames_buffer = filenames_buffer. to_vec ( ) ;
460
- // stop at null-terminator
461
- let filenames = match filenames_buffer. split ( |& e| e == 0 ) . next ( ) {
462
- Some ( filenames) => filenames,
463
- None => & filenames_buffer,
464
- } ;
465
- let filenames = String :: from_utf8 ( filenames. to_vec ( ) )
466
- . map_err ( |_| io:: Error :: new ( io:: ErrorKind :: InvalidData , "Path contained a null byte" ) ) ?;
467
- let paths = filenames
468
- . split ( '\n' )
469
- . map ( |filename| {
470
- let mut path = PathBuf :: new ( ) ;
471
- path. push ( p) ;
472
- path. push ( filename) ;
473
- DirEntry { path }
474
- } )
475
- . collect :: < Vec < _ > > ( ) ;
476
-
477
- Ok ( ReadDir { entries : paths } )
430
+ pub fn readdir ( _p : & Path ) -> io:: Result < ReadDir > {
431
+ // While there *is* a userspace function for reading file directories,
432
+ // the necessary implementation cannot currently be done cleanly, as
433
+ // vexOS does not expose directory length to user programs.
434
+ //
435
+ // This means that we would need to create a large fixed-length buffer
436
+ // and hope that the folder's contents didn't exceed that buffer's length,
437
+ // which obviously isn't behavior we want to rely on in the standard library.
438
+ unsupported ( )
478
439
}
479
440
480
441
pub fn unlink ( _p : & Path ) -> io:: Result < ( ) > {
@@ -522,7 +483,7 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
522
483
}
523
484
524
485
pub fn lstat ( p : & Path ) -> io:: Result < FileAttr > {
525
- // Symlinks aren't supported in our filesystem
486
+ // Symlinks aren't supported in this filesystem
526
487
stat ( p)
527
488
}
528
489
0 commit comments