1
Fork 0

Fix some of the documentation std::io::fs.

This commit is contained in:
nham 2014-07-28 14:14:56 -04:00
parent 79e9f14abf
commit 96cf01138b

View file

@ -273,7 +273,7 @@ impl File {
/// ///
/// # Error /// # Error
/// ///
/// This function will return an error if the path points to a directory, the /// This function will return an error if `path` points to a directory, if the
/// user lacks permissions to remove the file, or if some other filesystem-level /// user lacks permissions to remove the file, or if some other filesystem-level
/// error occurs. /// error occurs.
pub fn unlink(path: &Path) -> IoResult<()> { pub fn unlink(path: &Path) -> IoResult<()> {
@ -332,8 +332,8 @@ pub fn unlink(path: &Path) -> IoResult<()> {
/// ///
/// # Error /// # Error
/// ///
/// This call will return an error if the user lacks the requisite permissions /// This function will return an error if the user lacks the requisite permissions
/// to perform a `stat` call on the given path or if there is no entry in the /// to perform a `stat` call on the given `path` or if there is no entry in the
/// filesystem at the provided path. /// filesystem at the provided path.
pub fn stat(path: &Path) -> IoResult<FileStat> { pub fn stat(path: &Path) -> IoResult<FileStat> {
let err = match LocalIo::maybe_raise(|io| io.fs_stat(&path.to_c_str())) { let err = match LocalIo::maybe_raise(|io| io.fs_stat(&path.to_c_str())) {
@ -415,9 +415,9 @@ fn from_rtio(s: rtio::FileStat) -> FileStat {
/// ///
/// # Error /// # Error
/// ///
/// Will return an error if the provided `path` doesn't exist, the process lacks /// This function will return an error if the provided `from` doesn't exist, if
/// permissions to view the contents, or if some other intermittent I/O error /// the process lacks permissions to view the contents, or if some other
/// occurs. /// intermittent I/O error occurs.
pub fn rename(from: &Path, to: &Path) -> IoResult<()> { pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
let err = LocalIo::maybe_raise(|io| { let err = LocalIo::maybe_raise(|io| {
io.fs_rename(&from.to_c_str(), &to.to_c_str()) io.fs_rename(&from.to_c_str(), &to.to_c_str())
@ -444,8 +444,8 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
/// ///
/// # Error /// # Error
/// ///
/// Will return an error in the following situations, but is not limited to /// This function will return an error in the following situations, but is not
/// just these cases: /// limited to just these cases:
/// ///
/// * The `from` path is not a file /// * The `from` path is not a file
/// * The `from` file does not exist /// * The `from` file does not exist
@ -503,9 +503,9 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
/// ///
/// # Error /// # Error
/// ///
/// If this function encounters an I/O error, it will return an `Err` value. /// This function will return an error if the provided `path` doesn't exist, if
/// Some possible error situations are not having the permission to /// the process lacks permissions to change the attributes of the file, or if
/// change the attributes of a file or the file not existing. /// some other I/O error is encountered.
pub fn chmod(path: &Path, mode: io::FilePermission) -> IoResult<()> { pub fn chmod(path: &Path, mode: io::FilePermission) -> IoResult<()> {
let err = LocalIo::maybe_raise(|io| { let err = LocalIo::maybe_raise(|io| {
io.fs_chmod(&path.to_c_str(), mode.bits() as uint) io.fs_chmod(&path.to_c_str(), mode.bits() as uint)
@ -577,8 +577,8 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
/// ///
/// # Error /// # Error
/// ///
/// This call will return an error if the user lacks permissions to make a new /// This function will return an error if the user lacks permissions to make a
/// directory at the provided path, or if the directory already exists. /// new directory at the provided `path`, or if the directory already exists.
pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> { pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
let err = LocalIo::maybe_raise(|io| { let err = LocalIo::maybe_raise(|io| {
io.fs_mkdir(&path.to_c_str(), mode.bits() as uint) io.fs_mkdir(&path.to_c_str(), mode.bits() as uint)
@ -602,8 +602,8 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
/// ///
/// # Error /// # Error
/// ///
/// This call will return an error if the user lacks permissions to remove the /// This function will return an error if the user lacks permissions to remove
/// directory at the provided path, or if the directory isn't empty. /// the directory at the provided `path`, or if the directory isn't empty.
pub fn rmdir(path: &Path) -> IoResult<()> { pub fn rmdir(path: &Path) -> IoResult<()> {
let err = LocalIo::maybe_raise(|io| { let err = LocalIo::maybe_raise(|io| {
io.fs_rmdir(&path.to_c_str()) io.fs_rmdir(&path.to_c_str())
@ -640,9 +640,9 @@ pub fn rmdir(path: &Path) -> IoResult<()> {
/// ///
/// # Error /// # Error
/// ///
/// Will return an error if the provided `from` doesn't exist, the process lacks /// This function will return an error if the provided `path` doesn't exist, if
/// permissions to view the contents or if the `path` points at a non-directory /// the process lacks permissions to view the contents or if the `path` points
/// file /// at a non-directory file
pub fn readdir(path: &Path) -> IoResult<Vec<Path>> { pub fn readdir(path: &Path) -> IoResult<Vec<Path>> {
let err = LocalIo::maybe_raise(|io| { let err = LocalIo::maybe_raise(|io| {
Ok(try!(io.fs_readdir(&path.to_c_str(), 0)).move_iter().map(|a| { Ok(try!(io.fs_readdir(&path.to_c_str(), 0)).move_iter().map(|a| {
@ -697,8 +697,7 @@ impl Iterator<Path> for Directories {
/// ///
/// # Error /// # Error
/// ///
/// This function will return an `Err` value if an error happens, see /// See `fs::mkdir`.
/// `fs::mkdir` for more information about error conditions and performance.
pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> { pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> {
// tjc: if directory exists but with different permissions, // tjc: if directory exists but with different permissions,
// should we return false? // should we return false?
@ -735,8 +734,7 @@ pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> {
/// ///
/// # Error /// # Error
/// ///
/// This function will return an `Err` value if an error happens. See /// See `file::unlink` and `fs::readdir`
/// `file::unlink` and `fs::readdir` for possible error conditions.
pub fn rmdir_recursive(path: &Path) -> IoResult<()> { pub fn rmdir_recursive(path: &Path) -> IoResult<()> {
let mut rm_stack = Vec::new(); let mut rm_stack = Vec::new();
rm_stack.push(path.clone()); rm_stack.push(path.clone());