@@ -758,11 +758,19 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
758
758
/// guarantee that the file is immediately deleted (e.g. depending on
759
759
/// platform, other open file descriptors may prevent immediate removal).
760
760
///
761
+ /// # Platform behavior
762
+ ///
763
+ /// This function currently corresponds to the `unlink` function on Unix
764
+ /// and the `DeleteFile` function on Windows. Note that, this
765
+ /// [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
766
+ ///
761
767
/// # Errors
762
768
///
763
- /// This function will return an error if `path` points to a directory, if the
764
- /// user lacks permissions to remove the file, or if some other filesystem-level
765
- /// error occurs.
769
+ /// This function will return an error in the following situations, but is not
770
+ /// limited to just these cases:
771
+ ///
772
+ /// * `path` points to a directory
773
+ /// * The user lacks permissions to remove the file
766
774
///
767
775
/// # Examples
768
776
///
@@ -785,6 +793,20 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
785
793
/// This function will traverse symbolic links to query information about the
786
794
/// destination file.
787
795
///
796
+ /// # Platform behavior
797
+ ///
798
+ /// This function currently corresponds to the `stat` function on Unix
799
+ /// and the `GetFileAttributesEx` function on Windows. Note that, this
800
+ /// [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
801
+ ///
802
+ /// # Errors
803
+ ///
804
+ /// This function will return an error in the following situations, but is not
805
+ /// limited to just these cases:
806
+ ///
807
+ /// * The user lacks permissions to perform `metadata` call on `path`
808
+ /// * `path` does not exist
809
+ ///
788
810
/// # Examples
789
811
///
790
812
/// ```rust
@@ -796,19 +818,27 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
796
818
/// # Ok(())
797
819
/// # }
798
820
/// ```
799
- ///
800
- /// # Errors
801
- ///
802
- /// This function will return an error if the user lacks the requisite
803
- /// permissions to perform a `metadata` call on the given `path` or if there
804
- /// is no entry in the filesystem at the provided path.
805
821
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
806
822
pub fn metadata < P : AsRef < Path > > ( path : P ) -> io:: Result < Metadata > {
807
823
fs_imp:: stat ( path. as_ref ( ) ) . map ( Metadata )
808
824
}
809
825
810
826
/// Query the metadata about a file without following symlinks.
811
827
///
828
+ /// # Platform behavior
829
+ ///
830
+ /// This function currently corresponds to the `lstat` function on Unix
831
+ /// and the `GetFileAttributesEx` function on Windows. Note that, this
832
+ /// [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
833
+ ///
834
+ /// # Errors
835
+ ///
836
+ /// This function will return an error in the following situations, but is not
837
+ /// limited to just these cases:
838
+ ///
839
+ /// * The user lacks permissions to perform `metadata` call on `path`
840
+ /// * `path` does not exist
841
+ ///
812
842
/// # Examples
813
843
///
814
844
/// ```rust
@@ -829,12 +859,20 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
829
859
///
830
860
/// This will not work if the new name is on a different mount point.
831
861
///
862
+ /// # Platform behavior
863
+ ///
864
+ /// This function currently corresponds to the `rename` function on Unix
865
+ /// and the `MoveFileEx` function with the `MOVEFILE_REPLACE_EXISTING` flag on Windows.
866
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
867
+ ///
832
868
/// # Errors
833
869
///
834
- /// This function will return an error if the provided `from` doesn't exist, if
835
- /// the process lacks permissions to view the contents, if `from` and `to`
836
- /// reside on separate filesystems, or if some other intermittent I/O error
837
- /// occurs.
870
+ /// This function will return an error in the following situations, but is not
871
+ /// limited to just these cases:
872
+ ///
873
+ /// * `from` does not exist
874
+ /// * The user lacks permissions to view contents
875
+ /// * `from` and `to` are on separate filesystems
838
876
///
839
877
/// # Examples
840
878
///
@@ -861,6 +899,14 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
861
899
///
862
900
/// On success, the total number of bytes copied is returned.
863
901
///
902
+ /// # Platform behavior
903
+ ///
904
+ /// This function currently corresponds to the `open` function in Unix
905
+ /// with `O_RDONLY` for `from` and `O_WRONLY`, `O_CREAT`, and `O_TRUNC` for `to`.
906
+ /// `O_CLOEXEC` is set for returned file descriptors.
907
+ /// On Windows, this function currently corresponds to `CopyFileEx`.
908
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
909
+ ///
864
910
/// # Errors
865
911
///
866
912
/// This function will return an error in the following situations, but is not
@@ -890,6 +936,19 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
890
936
/// The `dst` path will be a link pointing to the `src` path. Note that systems
891
937
/// often require these two paths to both be located on the same filesystem.
892
938
///
939
+ /// # Platform behavior
940
+ ///
941
+ /// This function currently corresponds to the `link` function on Unix
942
+ /// and the `CreateHardLink` function on Windows.
943
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
944
+ ///
945
+ /// # Errors
946
+ ///
947
+ /// This function will return an error in the following situations, but is not
948
+ /// limited to just these cases:
949
+ ///
950
+ /// * The `src` path is not a file or doesn't exist
951
+ ///
893
952
/// # Examples
894
953
///
895
954
/// ```
@@ -933,11 +992,20 @@ pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
933
992
934
993
/// Reads a symbolic link, returning the file that the link points to.
935
994
///
995
+ /// # Platform behavior
996
+ ///
997
+ /// This function currently corresponds to the `readlink` function on Unix
998
+ /// and the `CreateFile` function with `FILE_FLAG_OPEN_REPARSE_POINT` and
999
+ /// `FILE_FLAG_BACKUP_SEMANTICS` flags on Windows.
1000
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
1001
+ ///
936
1002
/// # Errors
937
1003
///
938
- /// This function will return an error on failure. Failure conditions include
939
- /// reading a file that does not exist or reading a file that is not a symbolic
940
- /// link.
1004
+ /// This function will return an error in the following situations, but is not
1005
+ /// limited to just these cases:
1006
+ ///
1007
+ /// * `path` is not a symbolic link
1008
+ /// * `path` does not exist
941
1009
///
942
1010
/// # Examples
943
1011
///
@@ -957,8 +1025,19 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
957
1025
/// Returns the canonical form of a path with all intermediate components
958
1026
/// normalized and symbolic links resolved.
959
1027
///
960
- /// This function may return an error in situations like where the path does not
961
- /// exist, a component in the path is not a directory, or an I/O error happens.
1028
+ /// # Platform behavior
1029
+ ///
1030
+ /// This function currently corresponds to the `realpath` function on Unix
1031
+ /// and the `CreateFile` and `GetFinalPathNameByHandle` functions on Windows.
1032
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
1033
+ ///
1034
+ /// # Errors
1035
+ ///
1036
+ /// This function will return an error in the following situations, but is not
1037
+ /// limited to just these cases:
1038
+ ///
1039
+ /// * `path` does not exist
1040
+ /// * A component in path is not a directory
962
1041
///
963
1042
/// # Examples
964
1043
///
@@ -977,10 +1056,19 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
977
1056
978
1057
/// Creates a new, empty directory at the provided path
979
1058
///
1059
+ /// # Platform behavior
1060
+ ///
1061
+ /// This function currently corresponds to the `mkdir` function on Unix
1062
+ /// and the `CreateDirectory` function on Windows.
1063
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
1064
+ ///
980
1065
/// # Errors
981
1066
///
982
- /// This function will return an error if the user lacks permissions to make a
983
- /// new directory at the provided `path`, or if the directory already exists.
1067
+ /// This function will return an error in the following situations, but is not
1068
+ /// limited to just these cases:
1069
+ ///
1070
+ /// * User lacks permissions to create directory at `path`
1071
+ /// * `path` already exists
984
1072
///
985
1073
/// # Examples
986
1074
///
@@ -1000,9 +1088,18 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
1000
1088
/// Recursively create a directory and all of its parent components if they
1001
1089
/// are missing.
1002
1090
///
1091
+ /// # Platform behavior
1092
+ ///
1093
+ /// This function currently corresponds to the `mkdir` function on Unix
1094
+ /// and the `CreateDirectory` function on Windows.
1095
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
1096
+ ///
1003
1097
/// # Errors
1004
1098
///
1005
- /// This function will fail if any directory in the path specified by `path`
1099
+ /// This function will return an error in the following situations, but is not
1100
+ /// limited to just these cases:
1101
+ ///
1102
+ /// * If any directory in the path specified by `path`
1006
1103
/// does not already exist and it could not be created otherwise. The specific
1007
1104
/// error conditions for when a directory is being created (after it is
1008
1105
/// determined to not exist) are outlined by `fs::create_dir`.
@@ -1024,10 +1121,19 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
1024
1121
1025
1122
/// Removes an existing, empty directory.
1026
1123
///
1124
+ /// # Platform behavior
1125
+ ///
1126
+ /// This function currently corresponds to the `rmdir` function on Unix
1127
+ /// and the `RemoveDirectory` function on Windows.
1128
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
1129
+ ///
1027
1130
/// # Errors
1028
1131
///
1029
- /// This function will return an error if the user lacks permissions to remove
1030
- /// the directory at the provided `path`, or if the directory isn't empty.
1132
+ /// This function will return an error in the following situations, but is not
1133
+ /// limited to just these cases:
1134
+ ///
1135
+ /// * The user lacks permissions to remove the directory at the provided `path`
1136
+ /// * The directory isn't empty
1031
1137
///
1032
1138
/// # Examples
1033
1139
///
@@ -1050,6 +1156,13 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
1050
1156
/// This function does **not** follow symbolic links and it will simply remove the
1051
1157
/// symbolic link itself.
1052
1158
///
1159
+ /// # Platform behavior
1160
+ ///
1161
+ /// This function currently corresponds to `opendir`, `lstat`, `rm` and `rmdir` functions on Unix
1162
+ /// and the `FindFirstFile`, `GetFileAttributesEx`, `DeleteFile`, and `RemoveDirectory` functions
1163
+ /// on Windows.
1164
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
1165
+ ///
1053
1166
/// # Errors
1054
1167
///
1055
1168
/// See `file::remove_file` and `fs::remove_dir`.
@@ -1087,6 +1200,21 @@ fn _remove_dir_all(path: &Path) -> io::Result<()> {
1087
1200
/// The iterator will yield instances of `io::Result<DirEntry>`. New errors may
1088
1201
/// be encountered after an iterator is initially constructed.
1089
1202
///
1203
+ /// # Platform behavior
1204
+ ///
1205
+ /// This function currently corresponds to the `opendir` function on Unix
1206
+ /// and the `FindFirstFile` function on Windows.
1207
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
1208
+ ///
1209
+ /// # Errors
1210
+ ///
1211
+ /// This function will return an error in the following situations, but is not
1212
+ /// limited to just these cases:
1213
+ ///
1214
+ /// * The provided `path` doesn't exist
1215
+ /// * The process lacks permissions to view the contents
1216
+ /// * The `path` points at a non-directory file
1217
+ ///
1090
1218
/// # Examples
1091
1219
///
1092
1220
/// ```
@@ -1109,12 +1237,6 @@ fn _remove_dir_all(path: &Path) -> io::Result<()> {
1109
1237
/// Ok(())
1110
1238
/// }
1111
1239
/// ```
1112
- ///
1113
- /// # Errors
1114
- ///
1115
- /// This function will return an error if the provided `path` doesn't exist, if
1116
- /// the process lacks permissions to view the contents or if the `path` points
1117
- /// at a non-directory file
1118
1240
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1119
1241
pub fn read_dir < P : AsRef < Path > > ( path : P ) -> io:: Result < ReadDir > {
1120
1242
fs_imp:: readdir ( path. as_ref ( ) ) . map ( ReadDir )
@@ -1180,6 +1302,20 @@ impl Iterator for WalkDir {
1180
1302
1181
1303
/// Changes the permissions found on a file or a directory.
1182
1304
///
1305
+ /// # Platform behavior
1306
+ ///
1307
+ /// This function currently corresponds to the `chmod` function on Unix
1308
+ /// and the `SetFileAttributes` function on Windows.
1309
+ /// Note that, this [may change in the future.][https://github.com/rust-lang/rust/pull/28613]
1310
+ ///
1311
+ /// # Errors
1312
+ ///
1313
+ /// This function will return an error in the following situations, but is not
1314
+ /// limited to just these cases:
1315
+ ///
1316
+ /// * `path` does not exist
1317
+ /// * The user lacks the permission to change attributes of the file
1318
+ ///
1183
1319
/// # Examples
1184
1320
///
1185
1321
/// ```
@@ -1192,12 +1328,6 @@ impl Iterator for WalkDir {
1192
1328
/// # Ok(())
1193
1329
/// # }
1194
1330
/// ```
1195
- ///
1196
- /// # Errors
1197
- ///
1198
- /// This function will return an error if the provided `path` doesn't exist, if
1199
- /// the process lacks permissions to change the attributes of the file, or if
1200
- /// some other I/O error is encountered.
1201
1331
#[ stable( feature = "set_permissions" , since = "1.1.0" ) ]
1202
1332
pub fn set_permissions < P : AsRef < Path > > ( path : P , perm : Permissions )
1203
1333
-> io:: Result < ( ) > {
0 commit comments