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 {
5555 }
5656
5757 pub fn file_type ( & self ) -> FileType {
58- FileType {
59- is_dir : false ,
60- }
58+ FileType { is_dir : false }
6159 }
6260
6361 pub fn modified ( & self ) -> io:: Result < SystemTime > {
@@ -358,21 +356,19 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
358356
359357 let end = unsafe {
360358 let cur = vex_sdk:: vexFileTell ( fd) ;
359+ if cur < 0 {
360+ return Err ( io:: Error :: new ( io:: ErrorKind :: NotSeekable , "Failed to seek file" ) ) ;
361+ }
361362 map_fresult ( vex_sdk:: vexFileSeek ( fd, 0 , SEEK_END ) ) ?;
362363 let end = vex_sdk:: vexFileTell ( fd) ;
363364 map_fresult ( vex_sdk:: vexFileSeek ( fd, cur as _ , SEEK_SET ) ) ?;
364365 end
365366 } ;
366367
367368 if end >= 0 {
368- Ok ( FileAttr {
369- size : end as u64 ,
370- } )
369+ Ok ( FileAttr { size : end as u64 } )
371370 } 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" ) )
376372 }
377373}
378374
You can’t perform that action at this time.
0 commit comments