@@ -1823,76 +1823,98 @@ impl Path {
18231823 }
18241824
18251825
1826- /// Gets information on the file, directory, etc at this path .
1826+ /// Query the file system to get information about a file, directory, etc.
18271827 ///
1828- /// Consult the `fs::metadata` documentation for more info.
1828+ /// This function will traverse symbolic links to query information about the
1829+ /// destination file.
18291830 ///
1830- /// This call preserves identical runtime/error semantics with
1831- /// `fs::metadata`.
1831+ /// This is an alias to `fs::metadata`.
18321832 #[ stable( feature = "path_ext" , since = "1.5.0" ) ]
18331833 pub fn metadata ( & self ) -> io:: Result < fs:: Metadata > {
18341834 fs:: metadata ( self )
18351835 }
18361836
1837- /// Gets information on the file, directory, etc at this path .
1837+ /// Query the metadata about a file without following symlinks .
18381838 ///
1839- /// Consult the `fs::symlink_metadata` documentation for more info.
1840- ///
1841- /// This call preserves identical runtime/error semantics with
1842- /// `fs::symlink_metadata`.
1839+ /// This is an alias to `fs::symlink_metadata`.
18431840 #[ stable( feature = "path_ext" , since = "1.5.0" ) ]
18441841 pub fn symlink_metadata ( & self ) -> io:: Result < fs:: Metadata > {
18451842 fs:: symlink_metadata ( self )
18461843 }
18471844
1848- /// Returns the canonical form of a path, normalizing all components and
1849- /// eliminate all symlinks .
1845+ /// Returns the canonical form of the path with all intermediate components
1846+ /// normalized and symbolic links resolved .
18501847 ///
1851- /// This call preserves identical runtime/error semantics with
1852- /// `fs::canonicalize`.
1848+ /// This is an alias to `fs::canonicalize`.
18531849 #[ stable( feature = "path_ext" , since = "1.5.0" ) ]
18541850 pub fn canonicalize ( & self ) -> io:: Result < PathBuf > {
18551851 fs:: canonicalize ( self )
18561852 }
18571853
1858- /// Reads the symlink at this path .
1854+ /// Reads a symbolic link, returning the file that the link points to .
18591855 ///
1860- /// For more information see `fs::read_link`.
1856+ /// This is an alias to `fs::read_link`.
18611857 #[ stable( feature = "path_ext" , since = "1.5.0" ) ]
18621858 pub fn read_link ( & self ) -> io:: Result < PathBuf > {
18631859 fs:: read_link ( self )
18641860 }
18651861
1866- /// Reads the directory at this path.
1862+ /// Returns an iterator over the entries within a directory.
1863+ ///
1864+ /// The iterator will yield instances of `io::Result<DirEntry>`. New errors may
1865+ /// be encountered after an iterator is initially constructed.
18671866 ///
1868- /// For more information see `fs::read_dir`.
1867+ /// This is an alias to `fs::read_dir`.
18691868 #[ stable( feature = "path_ext" , since = "1.5.0" ) ]
18701869 pub fn read_dir ( & self ) -> io:: Result < fs:: ReadDir > {
18711870 fs:: read_dir ( self )
18721871 }
18731872
1874- /// Boolean value indicator whether the underlying file exists on the local
1875- /// filesystem. Returns false in exactly the cases where `fs::metadata`
1876- /// fails.
1873+ /// Returns whether the path points at an existing entity.
1874+ ///
1875+ /// This function will traverse symbolic links to query information about the
1876+ /// destination file. In case of broken symbolic links this will return `false`.
1877+ ///
1878+ /// # Examples
1879+ ///
1880+ /// ```no_run
1881+ /// use std::path::Path;
1882+ /// assert_eq!(Path::new("does_not_exist.txt").exists(), false);
1883+ /// ```
18771884 #[ stable( feature = "path_ext" , since = "1.5.0" ) ]
18781885 pub fn exists ( & self ) -> bool {
18791886 fs:: metadata ( self ) . is_ok ( )
18801887 }
18811888
1882- /// Whether the underlying implementation (be it a file path, or something
1883- /// else) points at a "regular file" on the FS. Will return false for paths
1884- /// to non-existent locations or directories or other non-regular files
1885- /// (named pipes, etc). Follows links when making this determination.
1889+ /// Returns whether the path is pointing at a regular file.
1890+ ///
1891+ /// This function will traverse symbolic links to query information about the
1892+ /// destination file. In case of broken symbolic links this will return `false`.
1893+ ///
1894+ /// # Examples
1895+ ///
1896+ /// ```no_run
1897+ /// use std::path::Path;
1898+ /// assert_eq!(Path::new("./is_a_directory/").is_file(), false);
1899+ /// assert_eq!(Path::new("a_file.txt").is_file(), true);
1900+ /// ```
18861901 #[ stable( feature = "path_ext" , since = "1.5.0" ) ]
18871902 pub fn is_file ( & self ) -> bool {
18881903 fs:: metadata ( self ) . map ( |m| m. is_file ( ) ) . unwrap_or ( false )
18891904 }
18901905
1891- /// Whether the underlying implementation (be it a file path, or something
1892- /// else) is pointing at a directory in the underlying FS. Will return
1893- /// false for paths to non-existent locations or if the item is not a
1894- /// directory (eg files, named pipes, etc). Follows links when making this
1895- /// determination.
1906+ /// Returns whether the path is pointing at a directory.
1907+ ///
1908+ /// This function will traverse symbolic links to query information about the
1909+ /// destination file. In case of broken symbolic links this will return `false`.
1910+ ///
1911+ /// # Examples
1912+ ///
1913+ /// ```no_run
1914+ /// use std::path::Path;
1915+ /// assert_eq!(Path::new("./is_a_directory/").is_dir(), true);
1916+ /// assert_eq!(Path::new("a_file.txt").is_dir(), false);
1917+ /// ```
18961918 #[ stable( feature = "path_ext" , since = "1.5.0" ) ]
18971919 pub fn is_dir ( & self ) -> bool {
18981920 fs:: metadata ( self ) . map ( |m| m. is_dir ( ) ) . unwrap_or ( false )
0 commit comments