@@ -297,20 +297,38 @@ impl FileAttr {
297
297
298
298
#[ cfg( not( target_os = "netbsd" ) ) ]
299
299
impl FileAttr {
300
+ #[ cfg( not( target_os = "vxworks" ) ) ]
300
301
pub fn modified ( & self ) -> io:: Result < SystemTime > {
301
302
Ok ( SystemTime :: from ( libc:: timespec {
302
303
tv_sec : self . stat . st_mtime as libc:: time_t ,
303
304
tv_nsec : self . stat . st_mtime_nsec as _ ,
304
305
} ) )
305
306
}
306
307
308
+ #[ cfg( target_os = "vxworks" ) ]
309
+ pub fn modified ( & self ) -> io:: Result < SystemTime > {
310
+ Ok ( SystemTime :: from ( libc:: timespec {
311
+ tv_sec : self . stat . st_mtime as libc:: time_t ,
312
+ tv_nsec : 0 ,
313
+ } ) )
314
+ }
315
+
316
+ #[ cfg( not( target_os = "vxworks" ) ) ]
307
317
pub fn accessed ( & self ) -> io:: Result < SystemTime > {
308
318
Ok ( SystemTime :: from ( libc:: timespec {
309
319
tv_sec : self . stat . st_atime as libc:: time_t ,
310
320
tv_nsec : self . stat . st_atime_nsec as _ ,
311
321
} ) )
312
322
}
313
323
324
+ #[ cfg( target_os = "vxworks" ) ]
325
+ pub fn accessed ( & self ) -> io:: Result < SystemTime > {
326
+ Ok ( SystemTime :: from ( libc:: timespec {
327
+ tv_sec : self . stat . st_atime as libc:: time_t ,
328
+ tv_nsec : 0 ,
329
+ } ) )
330
+ }
331
+
314
332
#[ cfg( any(
315
333
target_os = "freebsd" ,
316
334
target_os = "openbsd" ,
@@ -535,12 +553,22 @@ impl DirEntry {
535
553
lstat ( & self . path ( ) )
536
554
}
537
555
538
- #[ cfg( any( target_os = "solaris" , target_os = "illumos" , target_os = "haiku" ) ) ]
556
+ #[ cfg( any(
557
+ target_os = "solaris" ,
558
+ target_os = "illumos" ,
559
+ target_os = "haiku" ,
560
+ target_os = "vxworks"
561
+ ) ) ]
539
562
pub fn file_type ( & self ) -> io:: Result < FileType > {
540
563
lstat ( & self . path ( ) ) . map ( |m| m. file_type ( ) )
541
564
}
542
565
543
- #[ cfg( not( any( target_os = "solaris" , target_os = "illumos" , target_os = "haiku" ) ) ) ]
566
+ #[ cfg( not( any(
567
+ target_os = "solaris" ,
568
+ target_os = "illumos" ,
569
+ target_os = "haiku" ,
570
+ target_os = "vxworks"
571
+ ) ) ) ]
544
572
pub fn file_type ( & self ) -> io:: Result < FileType > {
545
573
match self . entry . d_type {
546
574
libc:: DT_CHR => Ok ( FileType { mode : libc:: S_IFCHR } ) ,
@@ -565,7 +593,8 @@ impl DirEntry {
565
593
target_os = "haiku" ,
566
594
target_os = "l4re" ,
567
595
target_os = "fuchsia" ,
568
- target_os = "redox"
596
+ target_os = "redox" ,
597
+ target_os = "vxworks"
569
598
) ) ]
570
599
pub fn ino ( & self ) -> u64 {
571
600
self . entry . d_ino as u64
@@ -603,7 +632,8 @@ impl DirEntry {
603
632
target_os = "linux" ,
604
633
target_os = "emscripten" ,
605
634
target_os = "l4re" ,
606
- target_os = "haiku"
635
+ target_os = "haiku" ,
636
+ target_os = "vxworks"
607
637
) ) ]
608
638
fn name_bytes ( & self ) -> & [ u8 ] {
609
639
unsafe { CStr :: from_ptr ( self . entry . d_name . as_ptr ( ) ) . to_bytes ( ) }
@@ -901,13 +931,25 @@ impl fmt::Debug for File {
901
931
Some ( PathBuf :: from ( OsString :: from_vec ( buf) ) )
902
932
}
903
933
904
- #[ cfg( not( any( target_os = "linux" , target_os = "macos" ) ) ) ]
934
+ #[ cfg( target_os = "vxworks" ) ]
935
+ fn get_path ( fd : c_int ) -> Option < PathBuf > {
936
+ let mut buf = vec ! [ 0 ; libc:: PATH_MAX as usize ] ;
937
+ let n = unsafe { libc:: ioctl ( fd, libc:: FIOGETNAME , buf. as_ptr ( ) ) } ;
938
+ if n == -1 {
939
+ return None ;
940
+ }
941
+ let l = buf. iter ( ) . position ( |& c| c == 0 ) . unwrap ( ) ;
942
+ buf. truncate ( l as usize ) ;
943
+ Some ( PathBuf :: from ( OsString :: from_vec ( buf) ) )
944
+ }
945
+
946
+ #[ cfg( not( any( target_os = "linux" , target_os = "macos" , target_os = "vxworks" ) ) ) ]
905
947
fn get_path ( _fd : c_int ) -> Option < PathBuf > {
906
948
// FIXME(#24570): implement this for other Unix platforms
907
949
None
908
950
}
909
951
910
- #[ cfg( any( target_os = "linux" , target_os = "macos" ) ) ]
952
+ #[ cfg( any( target_os = "linux" , target_os = "macos" , target_os = "vxworks" ) ) ]
911
953
fn get_mode ( fd : c_int ) -> Option < ( bool , bool ) > {
912
954
let mode = unsafe { libc:: fcntl ( fd, libc:: F_GETFL ) } ;
913
955
if mode == -1 {
@@ -921,7 +963,7 @@ impl fmt::Debug for File {
921
963
}
922
964
}
923
965
924
- #[ cfg( not( any( target_os = "linux" , target_os = "macos" ) ) ) ]
966
+ #[ cfg( not( any( target_os = "linux" , target_os = "macos" , target_os = "vxworks" ) ) ) ]
925
967
fn get_mode ( _fd : c_int ) -> Option < ( bool , bool ) > {
926
968
// FIXME(#24570): implement this for other Unix platforms
927
969
None
0 commit comments