@@ -55,19 +55,21 @@ impl FileAttr {
55
55
}
56
56
57
57
pub fn file_type ( & self ) -> FileType {
58
- todo ! ( )
58
+ FileType {
59
+ is_dir : false ,
60
+ }
59
61
}
60
62
61
63
pub fn modified ( & self ) -> io:: Result < SystemTime > {
62
- todo ! ( )
64
+ unsupported ( )
63
65
}
64
66
65
67
pub fn accessed ( & self ) -> io:: Result < SystemTime > {
66
- todo ! ( )
68
+ unsupported ( )
67
69
}
68
70
69
71
pub fn created ( & self ) -> io:: Result < SystemTime > {
70
- todo ! ( )
72
+ unsupported ( )
71
73
}
72
74
}
73
75
@@ -146,11 +148,7 @@ impl OpenOptions {
146
148
pub fn append ( & mut self , append : bool ) {
147
149
self . append = append;
148
150
}
149
- pub fn truncate ( & mut self , truncate : bool ) {
150
- if truncate {
151
- panic ! ( "Truncation is not supported" )
152
- }
153
- }
151
+ pub fn truncate ( & mut self , _truncate : bool ) { }
154
152
pub fn create ( & mut self , create : bool ) {
155
153
self . write = create;
156
154
}
@@ -169,14 +167,9 @@ impl File {
169
167
} ) ?;
170
168
171
169
if opts. create_new {
172
- let file_exists = unsafe {
173
- vex_sdk:: vexFileStatus ( path. as_ptr ( ) )
174
- } ;
170
+ let file_exists = unsafe { vex_sdk:: vexFileStatus ( path. as_ptr ( ) ) } ;
175
171
if file_exists != 0 {
176
- return Err ( io:: Error :: new (
177
- io:: ErrorKind :: AlreadyExists ,
178
- "File already exists"
179
- ) )
172
+ return Err ( io:: Error :: new ( io:: ErrorKind :: AlreadyExists , "File already exists" ) ) ;
180
173
}
181
174
}
182
175
@@ -335,18 +328,11 @@ pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
335
328
}
336
329
337
330
pub fn try_exists ( path : & Path ) -> io:: Result < bool > {
338
- let path = CString :: new ( path. as_os_str ( ) . as_encoded_bytes ( ) ) . map_err ( |_| {
339
- io:: Error :: new ( io:: ErrorKind :: InvalidData , "Path contained a null byte" )
340
- } ) ?;
331
+ let path = CString :: new ( path. as_os_str ( ) . as_encoded_bytes ( ) )
332
+ . map_err ( |_| io:: Error :: new ( io:: ErrorKind :: InvalidData , "Path contained a null byte" ) ) ?;
341
333
342
- let file_exists = unsafe {
343
- vex_sdk:: vexFileStatus ( path. as_ptr ( ) )
344
- } ;
345
- if file_exists != 0 {
346
- Ok ( true )
347
- } else {
348
- Ok ( false )
349
- }
334
+ let file_exists = unsafe { vex_sdk:: vexFileStatus ( path. as_ptr ( ) ) } ;
335
+ if file_exists != 0 { Ok ( true ) } else { Ok ( false ) }
350
336
}
351
337
352
338
pub fn readlink ( _p : & Path ) -> io:: Result < PathBuf > {
@@ -368,10 +354,14 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
368
354
let fd = file. fd . 0 ;
369
355
370
356
const SEEK_END : i32 = 2 ;
357
+ const SEEK_SET : i32 = 0 ;
371
358
372
359
let end = unsafe {
360
+ let cur = vex_sdk:: vexFileTell ( fd) ;
373
361
map_fresult ( vex_sdk:: vexFileSeek ( fd, 0 , SEEK_END ) ) ?;
374
- vex_sdk:: vexFileTell ( fd)
362
+ let end = vex_sdk:: vexFileTell ( fd) ;
363
+ map_fresult ( vex_sdk:: vexFileSeek ( fd, cur as _ , SEEK_SET ) ) ?;
364
+ end
375
365
} ;
376
366
377
367
if end >= 0 {
0 commit comments