@@ -297,20 +297,38 @@ impl FileAttr {
297297
298298#[ cfg( not( target_os = "netbsd" ) ) ]
299299impl FileAttr {
300+ #[ cfg( not( target_os = "vxworks" ) ) ]
300301 pub fn modified ( & self ) -> io:: Result < SystemTime > {
301302 Ok ( SystemTime :: from ( libc:: timespec {
302303 tv_sec : self . stat . st_mtime as libc:: time_t ,
303304 tv_nsec : self . stat . st_mtime_nsec as _ ,
304305 } ) )
305306 }
306307
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" ) ) ]
307317 pub fn accessed ( & self ) -> io:: Result < SystemTime > {
308318 Ok ( SystemTime :: from ( libc:: timespec {
309319 tv_sec : self . stat . st_atime as libc:: time_t ,
310320 tv_nsec : self . stat . st_atime_nsec as _ ,
311321 } ) )
312322 }
313323
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+
314332 #[ cfg( any(
315333 target_os = "freebsd" ,
316334 target_os = "openbsd" ,
@@ -535,12 +553,22 @@ impl DirEntry {
535553 lstat ( & self . path ( ) )
536554 }
537555
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+ ) ) ]
539562 pub fn file_type ( & self ) -> io:: Result < FileType > {
540563 lstat ( & self . path ( ) ) . map ( |m| m. file_type ( ) )
541564 }
542565
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+ ) ) ) ]
544572 pub fn file_type ( & self ) -> io:: Result < FileType > {
545573 match self . entry . d_type {
546574 libc:: DT_CHR => Ok ( FileType { mode : libc:: S_IFCHR } ) ,
@@ -565,7 +593,8 @@ impl DirEntry {
565593 target_os = "haiku" ,
566594 target_os = "l4re" ,
567595 target_os = "fuchsia" ,
568- target_os = "redox"
596+ target_os = "redox" ,
597+ target_os = "vxworks"
569598 ) ) ]
570599 pub fn ino ( & self ) -> u64 {
571600 self . entry . d_ino as u64
@@ -603,7 +632,8 @@ impl DirEntry {
603632 target_os = "linux" ,
604633 target_os = "emscripten" ,
605634 target_os = "l4re" ,
606- target_os = "haiku"
635+ target_os = "haiku" ,
636+ target_os = "vxworks"
607637 ) ) ]
608638 fn name_bytes ( & self ) -> & [ u8 ] {
609639 unsafe { CStr :: from_ptr ( self . entry . d_name . as_ptr ( ) ) . to_bytes ( ) }
@@ -901,13 +931,25 @@ impl fmt::Debug for File {
901931 Some ( PathBuf :: from ( OsString :: from_vec ( buf) ) )
902932 }
903933
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" ) ) ) ]
905947 fn get_path ( _fd : c_int ) -> Option < PathBuf > {
906948 // FIXME(#24570): implement this for other Unix platforms
907949 None
908950 }
909951
910- #[ cfg( any( target_os = "linux" , target_os = "macos" ) ) ]
952+ #[ cfg( any( target_os = "linux" , target_os = "macos" , target_os = "vxworks" ) ) ]
911953 fn get_mode ( fd : c_int ) -> Option < ( bool , bool ) > {
912954 let mode = unsafe { libc:: fcntl ( fd, libc:: F_GETFL ) } ;
913955 if mode == -1 {
@@ -921,7 +963,7 @@ impl fmt::Debug for File {
921963 }
922964 }
923965
924- #[ cfg( not( any( target_os = "linux" , target_os = "macos" ) ) ) ]
966+ #[ cfg( not( any( target_os = "linux" , target_os = "macos" , target_os = "vxworks" ) ) ) ]
925967 fn get_mode ( _fd : c_int ) -> Option < ( bool , bool ) > {
926968 // FIXME(#24570): implement this for other Unix platforms
927969 None
0 commit comments