@@ -715,7 +715,7 @@ impl DirEntry {
715715 /// This function will not traverse symlinks if this entry points at a
716716 /// symlink.
717717 ///
718- /// # Platform behavior
718+ /// # Platform-specific behavior
719719 ///
720720 /// On Windows this function is cheap to call (no extra system calls
721721 /// needed), but on Unix platforms this function is the equivalent of
@@ -730,7 +730,7 @@ impl DirEntry {
730730 /// This function will not traverse symlinks if this entry points at a
731731 /// symlink.
732732 ///
733- /// # Platform behavior
733+ /// # Platform-specific behavior
734734 ///
735735 /// On Windows and most Unix platforms this function is free (no extra
736736 /// system calls needed), but some Unix platforms may require the equivalent
@@ -758,11 +758,20 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
758758/// guarantee that the file is immediately deleted (e.g. depending on
759759/// platform, other open file descriptors may prevent immediate removal).
760760///
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+ ///
761768/// # Errors
762769///
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.
766775///
767776/// # Examples
768777///
@@ -785,6 +794,21 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
785794/// This function will traverse symbolic links to query information about the
786795/// destination file.
787796///
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+ ///
788812/// # Examples
789813///
790814/// ```rust
@@ -796,19 +820,28 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
796820/// # Ok(())
797821/// # }
798822/// ```
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.
805823#[ stable( feature = "rust1" , since = "1.0.0" ) ]
806824pub fn metadata < P : AsRef < Path > > ( path : P ) -> io:: Result < Metadata > {
807825 fs_imp:: stat ( path. as_ref ( ) ) . map ( Metadata )
808826}
809827
810828/// Query the metadata about a file without following symlinks.
811829///
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+ ///
812845/// # Examples
813846///
814847/// ```rust
@@ -829,12 +862,21 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
829862///
830863/// This will not work if the new name is on a different mount point.
831864///
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+ ///
832872/// # Errors
833873///
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.
838880///
839881/// # Examples
840882///
@@ -861,15 +903,24 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
861903///
862904/// On success, the total number of bytes copied is returned.
863905///
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+ ///
864915/// # Errors
865916///
866917/// This function will return an error in the following situations, but is not
867918/// limited to just these cases:
868919///
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.
871922/// * The current process does not have the permission rights to access
872- /// `from` or write `to`
923+ /// `from` or write `to`.
873924///
874925/// # Examples
875926///
@@ -890,6 +941,20 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
890941/// The `dst` path will be a link pointing to the `src` path. Note that systems
891942/// often require these two paths to both be located on the same filesystem.
892943///
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+ ///
893958/// # Examples
894959///
895960/// ```
@@ -933,11 +998,21 @@ pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
933998
934999/// Reads a symbolic link, returning the file that the link points to.
9351000///
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+ ///
9361009/// # Errors
9371010///
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.
9411016///
9421017/// # Examples
9431018///
@@ -957,8 +1032,20 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
9571032/// Returns the canonical form of a path with all intermediate components
9581033/// normalized and symbolic links resolved.
9591034///
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.
9621049///
9631050/// # Examples
9641051///
@@ -977,10 +1064,20 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
9771064
9781065/// Creates a new, empty directory at the provided path
9791066///
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+ ///
9801074/// # Errors
9811075///
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.
9841081///
9851082/// # Examples
9861083///
@@ -1000,9 +1097,19 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
10001097/// Recursively create a directory and all of its parent components if they
10011098/// are missing.
10021099///
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+ ///
10031107/// # Errors
10041108///
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`
10061113/// does not already exist and it could not be created otherwise. The specific
10071114/// error conditions for when a directory is being created (after it is
10081115/// 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<()> {
10241131
10251132/// Removes an existing, empty directory.
10261133///
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+ ///
10271141/// # Errors
10281142///
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.
10311148///
10321149/// # Examples
10331150///
@@ -1050,6 +1167,14 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
10501167/// This function does **not** follow symbolic links and it will simply remove the
10511168/// symbolic link itself.
10521169///
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+ ///
10531178/// # Errors
10541179///
10551180/// See `file::remove_file` and `fs::remove_dir`.
@@ -1087,6 +1212,22 @@ fn _remove_dir_all(path: &Path) -> io::Result<()> {
10871212/// The iterator will yield instances of `io::Result<DirEntry>`. New errors may
10881213/// be encountered after an iterator is initially constructed.
10891214///
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+ ///
10901231/// # Examples
10911232///
10921233/// ```
@@ -1109,12 +1250,6 @@ fn _remove_dir_all(path: &Path) -> io::Result<()> {
11091250/// Ok(())
11101251/// }
11111252/// ```
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
11181253#[ stable( feature = "rust1" , since = "1.0.0" ) ]
11191254pub fn read_dir < P : AsRef < Path > > ( path : P ) -> io:: Result < ReadDir > {
11201255 fs_imp:: readdir ( path. as_ref ( ) ) . map ( ReadDir )
@@ -1180,6 +1315,21 @@ impl Iterator for WalkDir {
11801315
11811316/// Changes the permissions found on a file or a directory.
11821317///
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+ ///
11831333/// # Examples
11841334///
11851335/// ```
@@ -1192,12 +1342,6 @@ impl Iterator for WalkDir {
11921342/// # Ok(())
11931343/// # }
11941344/// ```
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.
12011345#[ stable( feature = "set_permissions" , since = "1.1.0" ) ]
12021346pub fn set_permissions < P : AsRef < Path > > ( path : P , perm : Permissions )
12031347 -> io:: Result < ( ) > {
0 commit comments