@@ -715,7 +715,7 @@ impl DirEntry {
715
715
/// This function will not traverse symlinks if this entry points at a
716
716
/// symlink.
717
717
///
718
- /// # Platform behavior
718
+ /// # Platform-specific behavior
719
719
///
720
720
/// On Windows this function is cheap to call (no extra system calls
721
721
/// needed), but on Unix platforms this function is the equivalent of
@@ -730,7 +730,7 @@ impl DirEntry {
730
730
/// This function will not traverse symlinks if this entry points at a
731
731
/// symlink.
732
732
///
733
- /// # Platform behavior
733
+ /// # Platform-specific behavior
734
734
///
735
735
/// On Windows and most Unix platforms this function is free (no extra
736
736
/// system calls needed), but some Unix platforms may require the equivalent
@@ -758,11 +758,20 @@ 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-specific behavior
762
+ ///
763
+ /// This function currently corresponds to the `unlink` function on Unix
764
+ /// and the `DeleteFile` function on Windows.
765
+ /// Note that, this [may change in the future][changes].
766
+ /// [changes]: ../io/index.html#platform-specific-behavior
767
+ ///
761
768
/// # Errors
762
769
///
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.
770
+ /// This function will return an error in the following situations, but is not
771
+ /// limited to just these cases:
772
+ ///
773
+ /// * `path` points to a directory.
774
+ /// * The user lacks permissions to remove the file.
766
775
///
767
776
/// # Examples
768
777
///
@@ -785,6 +794,21 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
785
794
/// This function will traverse symbolic links to query information about the
786
795
/// destination file.
787
796
///
797
+ /// # Platform-specific behavior
798
+ ///
799
+ /// This function currently corresponds to the `stat` function on Unix
800
+ /// and the `GetFileAttributesEx` function on Windows.
801
+ /// Note that, this [may change in the future][changes].
802
+ /// [changes]: ../io/index.html#platform-specific-behavior
803
+ ///
804
+ /// # Errors
805
+ ///
806
+ /// This function will return an error in the following situations, but is not
807
+ /// limited to just these cases:
808
+ ///
809
+ /// * The user lacks permissions to perform `metadata` call on `path`.
810
+ /// * `path` does not exist.
811
+ ///
788
812
/// # Examples
789
813
///
790
814
/// ```rust
@@ -796,19 +820,28 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
796
820
/// # Ok(())
797
821
/// # }
798
822
/// ```
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
823
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
806
824
pub fn metadata < P : AsRef < Path > > ( path : P ) -> io:: Result < Metadata > {
807
825
fs_imp:: stat ( path. as_ref ( ) ) . map ( Metadata )
808
826
}
809
827
810
828
/// Query the metadata about a file without following symlinks.
811
829
///
830
+ /// # Platform-specific behavior
831
+ ///
832
+ /// This function currently corresponds to the `lstat` function on Unix
833
+ /// and the `GetFileAttributesEx` function on Windows.
834
+ /// Note that, this [may change in the future][changes].
835
+ /// [changes]: ../io/index.html#platform-specific-behavior
836
+ ///
837
+ /// # Errors
838
+ ///
839
+ /// This function will return an error in the following situations, but is not
840
+ /// limited to just these cases:
841
+ ///
842
+ /// * The user lacks permissions to perform `metadata` call on `path`.
843
+ /// * `path` does not exist.
844
+ ///
812
845
/// # Examples
813
846
///
814
847
/// ```rust
@@ -829,12 +862,21 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
829
862
///
830
863
/// This will not work if the new name is on a different mount point.
831
864
///
865
+ /// # Platform-specific behavior
866
+ ///
867
+ /// This function currently corresponds to the `rename` function on Unix
868
+ /// and the `MoveFileEx` function with the `MOVEFILE_REPLACE_EXISTING` flag on Windows.
869
+ /// Note that, this [may change in the future][changes].
870
+ /// [changes]: ../io/index.html#platform-specific-behavior
871
+ ///
832
872
/// # Errors
833
873
///
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.
874
+ /// This function will return an error in the following situations, but is not
875
+ /// limited to just these cases:
876
+ ///
877
+ /// * `from` does not exist.
878
+ /// * The user lacks permissions to view contents.
879
+ /// * `from` and `to` are on separate filesystems.
838
880
///
839
881
/// # Examples
840
882
///
@@ -861,15 +903,24 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
861
903
///
862
904
/// On success, the total number of bytes copied is returned.
863
905
///
906
+ /// # Platform-specific behavior
907
+ ///
908
+ /// This function currently corresponds to the `open` function in Unix
909
+ /// with `O_RDONLY` for `from` and `O_WRONLY`, `O_CREAT`, and `O_TRUNC` for `to`.
910
+ /// `O_CLOEXEC` is set for returned file descriptors.
911
+ /// On Windows, this function currently corresponds to `CopyFileEx`.
912
+ /// Note that, this [may change in the future][changes].
913
+ /// [changes]: ../io/index.html#platform-specific-behavior
914
+ ///
864
915
/// # Errors
865
916
///
866
917
/// This function will return an error in the following situations, but is not
867
918
/// limited to just these cases:
868
919
///
869
- /// * The `from` path is not a file
870
- /// * The `from` file does not exist
920
+ /// * The `from` path is not a file.
921
+ /// * The `from` file does not exist.
871
922
/// * The current process does not have the permission rights to access
872
- /// `from` or write `to`
923
+ /// `from` or write `to`.
873
924
///
874
925
/// # Examples
875
926
///
@@ -890,6 +941,20 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
890
941
/// The `dst` path will be a link pointing to the `src` path. Note that systems
891
942
/// often require these two paths to both be located on the same filesystem.
892
943
///
944
+ /// # Platform-specific behavior
945
+ ///
946
+ /// This function currently corresponds to the `link` function on Unix
947
+ /// and the `CreateHardLink` function on Windows.
948
+ /// Note that, this [may change in the future][changes].
949
+ /// [changes]: ../io/index.html#platform-specific-behavior
950
+ ///
951
+ /// # Errors
952
+ ///
953
+ /// This function will return an error in the following situations, but is not
954
+ /// limited to just these cases:
955
+ ///
956
+ /// * The `src` path is not a file or doesn't exist.
957
+ ///
893
958
/// # Examples
894
959
///
895
960
/// ```
@@ -933,11 +998,21 @@ pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
933
998
934
999
/// Reads a symbolic link, returning the file that the link points to.
935
1000
///
1001
+ /// # Platform-specific behavior
1002
+ ///
1003
+ /// This function currently corresponds to the `readlink` function on Unix
1004
+ /// and the `CreateFile` function with `FILE_FLAG_OPEN_REPARSE_POINT` and
1005
+ /// `FILE_FLAG_BACKUP_SEMANTICS` flags on Windows.
1006
+ /// Note that, this [may change in the future][changes].
1007
+ /// [changes]: ../io/index.html#platform-specific-behavior
1008
+ ///
936
1009
/// # Errors
937
1010
///
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.
1011
+ /// This function will return an error in the following situations, but is not
1012
+ /// limited to just these cases:
1013
+ ///
1014
+ /// * `path` is not a symbolic link.
1015
+ /// * `path` does not exist.
941
1016
///
942
1017
/// # Examples
943
1018
///
@@ -957,8 +1032,20 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
957
1032
/// Returns the canonical form of a path with all intermediate components
958
1033
/// normalized and symbolic links resolved.
959
1034
///
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.
1035
+ /// # Platform-specific behavior
1036
+ ///
1037
+ /// This function currently corresponds to the `realpath` function on Unix
1038
+ /// and the `CreateFile` and `GetFinalPathNameByHandle` functions on Windows.
1039
+ /// Note that, this [may change in the future][changes].
1040
+ /// [changes]: ../io/index.html#platform-specific-behavior
1041
+ ///
1042
+ /// # Errors
1043
+ ///
1044
+ /// This function will return an error in the following situations, but is not
1045
+ /// limited to just these cases:
1046
+ ///
1047
+ /// * `path` does not exist.
1048
+ /// * A component in path is not a directory.
962
1049
///
963
1050
/// # Examples
964
1051
///
@@ -977,10 +1064,20 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
977
1064
978
1065
/// Creates a new, empty directory at the provided path
979
1066
///
1067
+ /// # Platform-specific behavior
1068
+ ///
1069
+ /// This function currently corresponds to the `mkdir` function on Unix
1070
+ /// and the `CreateDirectory` function on Windows.
1071
+ /// Note that, this [may change in the future][changes].
1072
+ /// [changes]: ../io/index.html#platform-specific-behavior
1073
+ ///
980
1074
/// # Errors
981
1075
///
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.
1076
+ /// This function will return an error in the following situations, but is not
1077
+ /// limited to just these cases:
1078
+ ///
1079
+ /// * User lacks permissions to create directory at `path`.
1080
+ /// * `path` already exists.
984
1081
///
985
1082
/// # Examples
986
1083
///
@@ -1000,9 +1097,19 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
1000
1097
/// Recursively create a directory and all of its parent components if they
1001
1098
/// are missing.
1002
1099
///
1100
+ /// # Platform-specific behavior
1101
+ ///
1102
+ /// This function currently corresponds to the `mkdir` function on Unix
1103
+ /// and the `CreateDirectory` function on Windows.
1104
+ /// Note that, this [may change in the future][changes].
1105
+ /// [changes]: ../io/index.html#platform-specific-behavior
1106
+ ///
1003
1107
/// # Errors
1004
1108
///
1005
- /// This function will fail if any directory in the path specified by `path`
1109
+ /// This function will return an error in the following situations, but is not
1110
+ /// limited to just these cases:
1111
+ ///
1112
+ /// * If any directory in the path specified by `path`
1006
1113
/// does not already exist and it could not be created otherwise. The specific
1007
1114
/// error conditions for when a directory is being created (after it is
1008
1115
/// determined to not exist) are outlined by `fs::create_dir`.
@@ -1024,10 +1131,20 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
1024
1131
1025
1132
/// Removes an existing, empty directory.
1026
1133
///
1134
+ /// # Platform-specific behavior
1135
+ ///
1136
+ /// This function currently corresponds to the `rmdir` function on Unix
1137
+ /// and the `RemoveDirectory` function on Windows.
1138
+ /// Note that, this [may change in the future][changes].
1139
+ /// [changes]: ../io/index.html#platform-specific-behavior
1140
+ ///
1027
1141
/// # Errors
1028
1142
///
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.
1143
+ /// This function will return an error in the following situations, but is not
1144
+ /// limited to just these cases:
1145
+ ///
1146
+ /// * The user lacks permissions to remove the directory at the provided `path`.
1147
+ /// * The directory isn't empty.
1031
1148
///
1032
1149
/// # Examples
1033
1150
///
@@ -1050,6 +1167,14 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
1050
1167
/// This function does **not** follow symbolic links and it will simply remove the
1051
1168
/// symbolic link itself.
1052
1169
///
1170
+ /// # Platform-specific behavior
1171
+ ///
1172
+ /// This function currently corresponds to `opendir`, `lstat`, `rm` and `rmdir` functions on Unix
1173
+ /// and the `FindFirstFile`, `GetFileAttributesEx`, `DeleteFile`, and `RemoveDirectory` functions
1174
+ /// on Windows.
1175
+ /// Note that, this [may change in the future][changes].
1176
+ /// [changes]: ../io/index.html#platform-specific-behavior
1177
+ ///
1053
1178
/// # Errors
1054
1179
///
1055
1180
/// See `file::remove_file` and `fs::remove_dir`.
@@ -1087,6 +1212,22 @@ fn _remove_dir_all(path: &Path) -> io::Result<()> {
1087
1212
/// The iterator will yield instances of `io::Result<DirEntry>`. New errors may
1088
1213
/// be encountered after an iterator is initially constructed.
1089
1214
///
1215
+ /// # Platform-specific behavior
1216
+ ///
1217
+ /// This function currently corresponds to the `opendir` function on Unix
1218
+ /// and the `FindFirstFile` function on Windows.
1219
+ /// Note that, this [may change in the future][changes].
1220
+ /// [changes]: ../io/index.html#platform-specific-behavior
1221
+ ///
1222
+ /// # Errors
1223
+ ///
1224
+ /// This function will return an error in the following situations, but is not
1225
+ /// limited to just these cases:
1226
+ ///
1227
+ /// * The provided `path` doesn't exist.
1228
+ /// * The process lacks permissions to view the contents.
1229
+ /// * The `path` points at a non-directory file.
1230
+ ///
1090
1231
/// # Examples
1091
1232
///
1092
1233
/// ```
@@ -1109,12 +1250,6 @@ fn _remove_dir_all(path: &Path) -> io::Result<()> {
1109
1250
/// Ok(())
1110
1251
/// }
1111
1252
/// ```
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
1253
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1119
1254
pub fn read_dir < P : AsRef < Path > > ( path : P ) -> io:: Result < ReadDir > {
1120
1255
fs_imp:: readdir ( path. as_ref ( ) ) . map ( ReadDir )
@@ -1180,6 +1315,21 @@ impl Iterator for WalkDir {
1180
1315
1181
1316
/// Changes the permissions found on a file or a directory.
1182
1317
///
1318
+ /// # Platform-specific behavior
1319
+ ///
1320
+ /// This function currently corresponds to the `chmod` function on Unix
1321
+ /// and the `SetFileAttributes` function on Windows.
1322
+ /// Note that, this [may change in the future][changes].
1323
+ /// [changes]: ../io/index.html#platform-specific-behavior
1324
+ ///
1325
+ /// # Errors
1326
+ ///
1327
+ /// This function will return an error in the following situations, but is not
1328
+ /// limited to just these cases:
1329
+ ///
1330
+ /// * `path` does not exist.
1331
+ /// * The user lacks the permission to change attributes of the file.
1332
+ ///
1183
1333
/// # Examples
1184
1334
///
1185
1335
/// ```
@@ -1192,12 +1342,6 @@ impl Iterator for WalkDir {
1192
1342
/// # Ok(())
1193
1343
/// # }
1194
1344
/// ```
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
1345
#[ stable( feature = "set_permissions" , since = "1.1.0" ) ]
1202
1346
pub fn set_permissions < P : AsRef < Path > > ( path : P , perm : Permissions )
1203
1347
-> io:: Result < ( ) > {
0 commit comments