File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
library/std/src/sys/pal/vexos Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,7 @@ impl FileAttr {
55
55
}
56
56
57
57
pub fn file_type ( & self ) -> FileType {
58
- FileType {
59
- is_dir : false ,
60
- }
58
+ FileType { is_dir : false }
61
59
}
62
60
63
61
pub fn modified ( & self ) -> io:: Result < SystemTime > {
@@ -358,21 +356,19 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
358
356
359
357
let end = unsafe {
360
358
let cur = vex_sdk:: vexFileTell ( fd) ;
359
+ if cur < 0 {
360
+ return Err ( io:: Error :: new ( io:: ErrorKind :: NotSeekable , "Failed to seek file" ) ) ;
361
+ }
361
362
map_fresult ( vex_sdk:: vexFileSeek ( fd, 0 , SEEK_END ) ) ?;
362
363
let end = vex_sdk:: vexFileTell ( fd) ;
363
364
map_fresult ( vex_sdk:: vexFileSeek ( fd, cur as _ , SEEK_SET ) ) ?;
364
365
end
365
366
} ;
366
367
367
368
if end >= 0 {
368
- Ok ( FileAttr {
369
- size : end as u64 ,
370
- } )
369
+ Ok ( FileAttr { size : end as u64 } )
371
370
} else {
372
- Err ( io:: Error :: new (
373
- io:: ErrorKind :: NotSeekable ,
374
- "Failed to seek file"
375
- ) )
371
+ Err ( io:: Error :: new ( io:: ErrorKind :: NotSeekable , "Failed to seek file" ) )
376
372
}
377
373
}
378
374
You can’t perform that action at this time.
0 commit comments