@@ -15,6 +15,7 @@ use crate::mem;
1515 target_os = "redox" ,
1616 target_os = "illumos" ,
1717 target_os = "nto" ,
18+ target_os = "vita" ,
1819) ) ]
1920use crate :: mem:: MaybeUninit ;
2021use crate :: os:: unix:: io:: { AsFd , AsRawFd , BorrowedFd , FromRawFd , IntoRawFd } ;
@@ -58,6 +59,7 @@ use libc::fstatat64;
5859 target_os = "redox" ,
5960 target_os = "illumos" ,
6061 target_os = "nto" ,
62+ target_os = "vita" ,
6163) ) ]
6264use libc:: readdir as readdir64;
6365#[ cfg( target_os = "linux" ) ]
@@ -74,6 +76,7 @@ use libc::readdir64_r;
7476 target_os = "fuchsia" ,
7577 target_os = "redox" ,
7678 target_os = "nto" ,
79+ target_os = "vita" ,
7780) ) ) ]
7881use libc:: readdir_r as readdir64_r;
7982#[ cfg( target_os = "android" ) ]
@@ -283,6 +286,7 @@ unsafe impl Sync for Dir {}
283286 target_os = "fuchsia" ,
284287 target_os = "redox" ,
285288 target_os = "nto" ,
289+ target_os = "vita"
286290) ) ]
287291pub struct DirEntry {
288292 dir : Arc < InnerReadDir > ,
@@ -304,10 +308,16 @@ pub struct DirEntry {
304308 target_os = "fuchsia" ,
305309 target_os = "redox" ,
306310 target_os = "nto" ,
311+ target_os = "vita" ,
307312) ) ]
308313struct dirent64_min {
309314 d_ino : u64 ,
310- #[ cfg( not( any( target_os = "solaris" , target_os = "illumos" , target_os = "nto" ) ) ) ]
315+ #[ cfg( not( any(
316+ target_os = "solaris" ,
317+ target_os = "illumos" ,
318+ target_os = "nto" ,
319+ target_os = "vita"
320+ ) ) ) ]
311321 d_type : u8 ,
312322}
313323
@@ -319,6 +329,7 @@ struct dirent64_min {
319329 target_os = "fuchsia" ,
320330 target_os = "redox" ,
321331 target_os = "nto" ,
332+ target_os = "vita" ,
322333) ) ) ]
323334pub struct DirEntry {
324335 dir : Arc < InnerReadDir > ,
@@ -520,6 +531,7 @@ impl FileAttr {
520531 target_os = "macos" ,
521532 target_os = "ios" ,
522533 target_os = "watchos" ,
534+ target_os = "vita" ,
523535 ) ) ) ]
524536 pub fn created ( & self ) -> io:: Result < SystemTime > {
525537 cfg_has_statx ! {
@@ -541,6 +553,11 @@ impl FileAttr {
541553 currently",
542554 ) )
543555 }
556+
557+ #[ cfg( target_os = "vita" ) ]
558+ pub fn created ( & self ) -> io:: Result < SystemTime > {
559+ Ok ( SystemTime :: new ( self . stat . st_ctime as i64 , 0 ) )
560+ }
544561}
545562
546563#[ cfg( target_os = "nto" ) ]
@@ -645,6 +662,7 @@ impl Iterator for ReadDir {
645662 target_os = "redox" ,
646663 target_os = "illumos" ,
647664 target_os = "nto" ,
665+ target_os = "vita" ,
648666 ) ) ]
649667 fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
650668 if self . end_of_stream {
@@ -725,6 +743,7 @@ impl Iterator for ReadDir {
725743 continue ;
726744 }
727745
746+ #[ cfg( not( target_os = "vita" ) ) ]
728747 let entry = dirent64_min {
729748 d_ino : * offset_ptr ! ( entry_ptr, d_ino) as u64 ,
730749 #[ cfg( not( any(
@@ -735,6 +754,9 @@ impl Iterator for ReadDir {
735754 d_type : * offset_ptr ! ( entry_ptr, d_type) as u8 ,
736755 } ;
737756
757+ #[ cfg( target_os = "vita" ) ]
758+ let entry = dirent64_min { d_ino : 0u64 } ;
759+
738760 return Some ( Ok ( DirEntry {
739761 entry,
740762 name : name. to_owned ( ) ,
@@ -752,6 +774,7 @@ impl Iterator for ReadDir {
752774 target_os = "redox" ,
753775 target_os = "illumos" ,
754776 target_os = "nto" ,
777+ target_os = "vita" ,
755778 ) ) ) ]
756779 fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
757780 if self . end_of_stream {
@@ -842,6 +865,7 @@ impl DirEntry {
842865 target_os = "haiku" ,
843866 target_os = "vxworks" ,
844867 target_os = "nto" ,
868+ target_os = "vita" ,
845869 ) ) ]
846870 pub fn file_type ( & self ) -> io:: Result < FileType > {
847871 self . metadata ( ) . map ( |m| m. file_type ( ) )
@@ -853,6 +877,7 @@ impl DirEntry {
853877 target_os = "haiku" ,
854878 target_os = "vxworks" ,
855879 target_os = "nto" ,
880+ target_os = "vita" ,
856881 ) ) ) ]
857882 pub fn file_type ( & self ) -> io:: Result < FileType > {
858883 match self . entry . d_type {
@@ -939,6 +964,7 @@ impl DirEntry {
939964 target_os = "fuchsia" ,
940965 target_os = "redox" ,
941966 target_os = "nto" ,
967+ target_os = "vita" ,
942968 ) ) ) ]
943969 fn name_cstr ( & self ) -> & CStr {
944970 unsafe { CStr :: from_ptr ( self . entry . d_name . as_ptr ( ) ) }
@@ -951,6 +977,7 @@ impl DirEntry {
951977 target_os = "fuchsia" ,
952978 target_os = "redox" ,
953979 target_os = "nto" ,
980+ target_os = "vita" ,
954981 ) ) ]
955982 fn name_cstr ( & self ) -> & CStr {
956983 & self . name
@@ -1543,7 +1570,7 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
15431570 run_path_with_cstr ( original, |original| {
15441571 run_path_with_cstr ( link, |link| {
15451572 cfg_if:: cfg_if! {
1546- if #[ cfg( any( target_os = "vxworks" , target_os = "redox" , target_os = "android" , target_os = "espidf" , target_os = "horizon" ) ) ] {
1573+ if #[ cfg( any( target_os = "vxworks" , target_os = "redox" , target_os = "android" , target_os = "espidf" , target_os = "horizon" , target_os = "vita" ) ) ] {
15471574 // VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead. POSIX leaves
15481575 // it implementation-defined whether `link` follows symlinks, so rely on the
15491576 // `symlink_hard_link` test in library/std/src/fs/tests.rs to check the behavior.
@@ -1666,6 +1693,8 @@ fn open_to_and_set_permissions(
16661693 . truncate ( true )
16671694 . open ( to) ?;
16681695 let writer_metadata = writer. metadata ( ) ?;
1696+ // fchmod is broken on vita
1697+ #[ cfg( not( target_os = "vita" ) ) ]
16691698 if writer_metadata. is_file ( ) {
16701699 // Set the correct file permissions, in case the file already existed.
16711700 // Don't set the permissions on already existing non-files like
@@ -1844,11 +1873,12 @@ pub fn chroot(dir: &Path) -> io::Result<()> {
18441873
18451874pub use remove_dir_impl:: remove_dir_all;
18461875
1847- // Fallback for REDOX, ESP-ID, Horizon, and Miri
1876+ // Fallback for REDOX, ESP-ID, Horizon, Vita and Miri
18481877#[ cfg( any(
18491878 target_os = "redox" ,
18501879 target_os = "espidf" ,
18511880 target_os = "horizon" ,
1881+ target_os = "vita" ,
18521882 target_os = "nto" ,
18531883 miri
18541884) ) ]
@@ -1861,6 +1891,7 @@ mod remove_dir_impl {
18611891 target_os = "redox" ,
18621892 target_os = "espidf" ,
18631893 target_os = "horizon" ,
1894+ target_os = "vita" ,
18641895 target_os = "nto" ,
18651896 miri
18661897) ) ) ]
0 commit comments