@@ -148,7 +148,7 @@ pub struct OpenOptions(fs_imp::OpenOptions);
148
148
pub struct Permissions ( fs_imp:: FilePermissions ) ;
149
149
150
150
/// An structure representing a type of file with accessors for each file type.
151
- #[ unstable ( feature = "file_type" , reason = "recently added API " ) ]
151
+ #[ stable ( feature = "file_type" , since = "1.1.0 " ) ]
152
152
#[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
153
153
pub struct FileType ( fs_imp:: FileType ) ;
154
154
@@ -208,14 +208,6 @@ impl File {
208
208
OpenOptions :: new ( ) . write ( true ) . create ( true ) . truncate ( true ) . open ( path)
209
209
}
210
210
211
- /// Returns `None`.
212
- #[ unstable( feature = "file_path" ,
213
- reason = "this abstraction was imposed by this library and was removed" ) ]
214
- #[ deprecated( since = "1.0.0" , reason = "abstraction was removed" ) ]
215
- pub fn path ( & self ) -> Option < & Path > {
216
- None
217
- }
218
-
219
211
/// Attempts to sync all OS-internal metadata to disk.
220
212
///
221
213
/// This function will attempt to ensure that all in-core data reaches the
@@ -501,7 +493,7 @@ impl AsInnerMut<fs_imp::OpenOptions> for OpenOptions {
501
493
502
494
impl Metadata {
503
495
/// Returns the file type for this metadata.
504
- #[ unstable ( feature = "file_type" , reason = "recently added API " ) ]
496
+ #[ stable ( feature = "file_type" , since = "1.1.0 " ) ]
505
497
pub fn file_type ( & self ) -> FileType {
506
498
FileType ( self . 0 . file_type ( ) )
507
499
}
@@ -575,38 +567,6 @@ impl Metadata {
575
567
pub fn permissions ( & self ) -> Permissions {
576
568
Permissions ( self . 0 . perm ( ) )
577
569
}
578
-
579
- /// Returns the most recent access time for a file.
580
- ///
581
- /// The return value is in milliseconds since the epoch.
582
- #[ unstable( feature = "fs_time" ,
583
- reason = "the return type of u64 is not quite appropriate for \
584
- this method and may change if the standard library \
585
- gains a type to represent a moment in time") ]
586
- #[ deprecated( since = "1.1.0" ,
587
- reason = "use os::platform::fs::MetadataExt extension traits" ) ]
588
- pub fn accessed ( & self ) -> u64 {
589
- self . adjust_time ( self . 0 . accessed ( ) )
590
- }
591
-
592
- /// Returns the most recent modification time for a file.
593
- ///
594
- /// The return value is in milliseconds since the epoch.
595
- #[ unstable( feature = "fs_time" ,
596
- reason = "the return type of u64 is not quite appropriate for \
597
- this method and may change if the standard library \
598
- gains a type to represent a moment in time") ]
599
- #[ deprecated( since = "1.1.0" ,
600
- reason = "use os::platform::fs::MetadataExt extension traits" ) ]
601
- pub fn modified ( & self ) -> u64 {
602
- self . adjust_time ( self . 0 . modified ( ) )
603
- }
604
-
605
- fn adjust_time ( & self , val : u64 ) -> u64 {
606
- // FILETIME (what `val` represents) is in 100ns intervals and there are
607
- // 10000 intervals in a millisecond.
608
- if cfg ! ( windows) { val / 10000 } else { val}
609
- }
610
570
}
611
571
612
572
impl AsInner < fs_imp:: FileAttr > for Metadata {
@@ -663,15 +623,17 @@ impl Permissions {
663
623
}
664
624
}
665
625
666
- #[ unstable( feature = "file_type" , reason = "recently added API" ) ]
667
626
impl FileType {
668
627
/// Test whether this file type represents a directory.
628
+ #[ stable( feature = "file_type" , since = "1.1.0" ) ]
669
629
pub fn is_dir ( & self ) -> bool { self . 0 . is_dir ( ) }
670
630
671
631
/// Test whether this file type represents a regular file.
632
+ #[ stable( feature = "file_type" , since = "1.1.0" ) ]
672
633
pub fn is_file ( & self ) -> bool { self . 0 . is_file ( ) }
673
634
674
635
/// Test whether this file type represents a symbolic link.
636
+ #[ stable( feature = "file_type" , since = "1.1.0" ) ]
675
637
pub fn is_symlink ( & self ) -> bool { self . 0 . is_symlink ( ) }
676
638
}
677
639
@@ -736,7 +698,7 @@ impl DirEntry {
736
698
/// On Windows this function is cheap to call (no extra system calls
737
699
/// needed), but on Unix platforms this function is the equivalent of
738
700
/// calling `symlink_metadata` on the path.
739
- #[ unstable ( feature = "dir_entry_ext" , reason = "recently added API " ) ]
701
+ #[ stable ( feature = "dir_entry_ext" , since = "1.1.0 " ) ]
740
702
pub fn metadata ( & self ) -> io:: Result < Metadata > {
741
703
self . 0 . metadata ( ) . map ( Metadata )
742
704
}
@@ -751,14 +713,14 @@ impl DirEntry {
751
713
/// On Windows and most Unix platforms this function is free (no extra
752
714
/// system calls needed), but some Unix platforms may require the equivalent
753
715
/// call to `symlink_metadata` to learn about the target file type.
754
- #[ unstable ( feature = "dir_entry_ext" , reason = "recently added API " ) ]
716
+ #[ stable ( feature = "dir_entry_ext" , since = "1.1.0 " ) ]
755
717
pub fn file_type ( & self ) -> io:: Result < FileType > {
756
718
self . 0 . file_type ( ) . map ( FileType )
757
719
}
758
720
759
721
/// Returns the bare file name of this directory entry without any other
760
722
/// leading path component.
761
- #[ unstable ( feature = "dir_entry_ext" , reason = "recently added API " ) ]
723
+ #[ stable ( feature = "dir_entry_ext" , since = "1.1.0 " ) ]
762
724
pub fn file_name ( & self ) -> OsString {
763
725
self . 0 . file_name ( )
764
726
}
@@ -828,7 +790,6 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
828
790
/// # Examples
829
791
///
830
792
/// ```rust
831
- /// #![feature(symlink_metadata)]
832
793
/// # fn foo() -> std::io::Result<()> {
833
794
/// use std::fs;
834
795
///
@@ -837,7 +798,7 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
837
798
/// # Ok(())
838
799
/// # }
839
800
/// ```
840
- #[ unstable ( feature = "symlink_metadata" , reason = "recently added API " ) ]
801
+ #[ stable ( feature = "symlink_metadata" , since = "1.1.0 " ) ]
841
802
pub fn symlink_metadata < P : AsRef < Path > > ( path : P ) -> io:: Result < Metadata > {
842
803
fs_imp:: lstat ( path. as_ref ( ) ) . map ( Metadata )
843
804
}
@@ -1268,7 +1229,6 @@ pub fn set_file_times<P: AsRef<Path>>(path: P, accessed: u64,
1268
1229
/// # Examples
1269
1230
///
1270
1231
/// ```
1271
- /// # #![feature(fs)]
1272
1232
/// # fn foo() -> std::io::Result<()> {
1273
1233
/// use std::fs;
1274
1234
///
@@ -1284,14 +1244,13 @@ pub fn set_file_times<P: AsRef<Path>>(path: P, accessed: u64,
1284
1244
/// This function will return an error if the provided `path` doesn't exist, if
1285
1245
/// the process lacks permissions to change the attributes of the file, or if
1286
1246
/// some other I/O error is encountered.
1287
- #[ unstable( feature = "fs" ,
1288
- reason = "a more granual ability to set specific permissions may \
1289
- be exposed on the Permissions structure itself and this \
1290
- method may not always exist") ]
1291
- pub fn set_permissions < P : AsRef < Path > > ( path : P , perm : Permissions ) -> io:: Result < ( ) > {
1247
+ #[ stable( feature = "set_permissions" , since = "1.1.0" ) ]
1248
+ pub fn set_permissions < P : AsRef < Path > > ( path : P , perm : Permissions )
1249
+ -> io:: Result < ( ) > {
1292
1250
fs_imp:: set_perm ( path. as_ref ( ) , perm. 0 )
1293
1251
}
1294
1252
1253
+ #[ unstable( feature = "dir_builder" , reason = "recently added API" ) ]
1295
1254
impl DirBuilder {
1296
1255
/// Creates a new set of options with default mode/security settings for all
1297
1256
/// platforms and also non-recursive.
@@ -2064,9 +2023,24 @@ mod tests {
2064
2023
// These numbers have to be bigger than the time in the day to account
2065
2024
// for timezones Windows in particular will fail in certain timezones
2066
2025
// with small enough values
2067
- check ! ( fs:: set_file_times( & path, 100000 , 200000 ) ) ;
2068
- assert_eq ! ( check!( path. metadata( ) ) . accessed( ) , 100000 ) ;
2069
- assert_eq ! ( check!( path. metadata( ) ) . modified( ) , 200000 ) ;
2026
+ check ! ( fs:: set_file_times( & path, 100_000 , 200_000 ) ) ;
2027
+
2028
+ check ( & check ! ( path. metadata( ) ) ) ;
2029
+
2030
+ #[ cfg( unix) ]
2031
+ fn check ( metadata : & fs:: Metadata ) {
2032
+ use os:: unix:: prelude:: * ;
2033
+ assert_eq ! ( metadata. atime( ) , 100 ) ;
2034
+ assert_eq ! ( metadata. atime_nsec( ) , 0 ) ;
2035
+ assert_eq ! ( metadata. mtime( ) , 200 ) ;
2036
+ assert_eq ! ( metadata. mtime_nsec( ) , 0 ) ;
2037
+ }
2038
+ #[ cfg( windows) ]
2039
+ fn check ( metadata : & fs:: Metadata ) {
2040
+ use os:: windows:: prelude:: * ;
2041
+ assert_eq ! ( metadata. last_access_time( ) , 100_000 * 10_000 ) ;
2042
+ assert_eq ! ( metadata. last_write_time( ) , 200_000 * 10_000 ) ;
2043
+ }
2070
2044
}
2071
2045
2072
2046
#[ test]
0 commit comments