Skip to content

Commit 1c04939

Browse files
committed
auto merge of #16052 : nham/rust/fs_docs, r=brson
Some of the fixes include: - fixing mismatch between the documentation and the function parameters. (i.e. documentation references `path` parameter, but it's actually called `from`, or vice versa) - A few Error sections were missing an "if" on the middle clause. For example, they used to be: "This function will return an error if [Thing], [Another Thing], or if [Yet Another Thing]." I added an "if" so it becomes "This function will return an error if [Thing], if [Another Thing], or if [Yet Another Thing]" - The error sections previously started off with 3 different phrases: - "This function will return an error if ..." - "Will return an error if ..." - "This call will return an error if ..." I've standardized on the first phrase.
2 parents 72e2c7d + 96cf011 commit 1c04939

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/libstd/io/fs.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl File {
273273
///
274274
/// # Error
275275
///
276-
/// This function will return an error if the path points to a directory, the
276+
/// This function will return an error if `path` points to a directory, if the
277277
/// user lacks permissions to remove the file, or if some other filesystem-level
278278
/// error occurs.
279279
pub fn unlink(path: &Path) -> IoResult<()> {
@@ -332,8 +332,8 @@ pub fn unlink(path: &Path) -> IoResult<()> {
332332
///
333333
/// # Error
334334
///
335-
/// This call will return an error if the user lacks the requisite permissions
336-
/// to perform a `stat` call on the given path or if there is no entry in the
335+
/// This function will return an error if the user lacks the requisite permissions
336+
/// to perform a `stat` call on the given `path` or if there is no entry in the
337337
/// filesystem at the provided path.
338338
pub fn stat(path: &Path) -> IoResult<FileStat> {
339339
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 {
415415
///
416416
/// # Error
417417
///
418-
/// Will return an error if the provided `path` doesn't exist, the process lacks
419-
/// permissions to view the contents, or if some other intermittent I/O error
420-
/// occurs.
418+
/// This function will return an error if the provided `from` doesn't exist, if
419+
/// the process lacks permissions to view the contents, or if some other
420+
/// intermittent I/O error occurs.
421421
pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
422422
let err = LocalIo::maybe_raise(|io| {
423423
io.fs_rename(&from.to_c_str(), &to.to_c_str())
@@ -444,8 +444,8 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
444444
///
445445
/// # Error
446446
///
447-
/// Will return an error in the following situations, but is not limited to
448-
/// just these cases:
447+
/// This function will return an error in the following situations, but is not
448+
/// limited to just these cases:
449449
///
450450
/// * The `from` path is not a file
451451
/// * The `from` file does not exist
@@ -503,9 +503,9 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
503503
///
504504
/// # Error
505505
///
506-
/// If this function encounters an I/O error, it will return an `Err` value.
507-
/// Some possible error situations are not having the permission to
508-
/// change the attributes of a file or the file not existing.
506+
/// This function will return an error if the provided `path` doesn't exist, if
507+
/// the process lacks permissions to change the attributes of the file, or if
508+
/// some other I/O error is encountered.
509509
pub fn chmod(path: &Path, mode: io::FilePermission) -> IoResult<()> {
510510
let err = LocalIo::maybe_raise(|io| {
511511
io.fs_chmod(&path.to_c_str(), mode.bits() as uint)
@@ -577,8 +577,8 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
577577
///
578578
/// # Error
579579
///
580-
/// This call will return an error if the user lacks permissions to make a new
581-
/// directory at the provided path, or if the directory already exists.
580+
/// This function will return an error if the user lacks permissions to make a
581+
/// new directory at the provided `path`, or if the directory already exists.
582582
pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
583583
let err = LocalIo::maybe_raise(|io| {
584584
io.fs_mkdir(&path.to_c_str(), mode.bits() as uint)
@@ -602,8 +602,8 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
602602
///
603603
/// # Error
604604
///
605-
/// This call will return an error if the user lacks permissions to remove the
606-
/// directory at the provided path, or if the directory isn't empty.
605+
/// This function will return an error if the user lacks permissions to remove
606+
/// the directory at the provided `path`, or if the directory isn't empty.
607607
pub fn rmdir(path: &Path) -> IoResult<()> {
608608
let err = LocalIo::maybe_raise(|io| {
609609
io.fs_rmdir(&path.to_c_str())
@@ -640,9 +640,9 @@ pub fn rmdir(path: &Path) -> IoResult<()> {
640640
///
641641
/// # Error
642642
///
643-
/// Will return an error if the provided `from` doesn't exist, the process lacks
644-
/// permissions to view the contents or if the `path` points at a non-directory
645-
/// file
643+
/// This function will return an error if the provided `path` doesn't exist, if
644+
/// the process lacks permissions to view the contents or if the `path` points
645+
/// at a non-directory file
646646
pub fn readdir(path: &Path) -> IoResult<Vec<Path>> {
647647
let err = LocalIo::maybe_raise(|io| {
648648
Ok(try!(io.fs_readdir(&path.to_c_str(), 0)).move_iter().map(|a| {
@@ -697,8 +697,7 @@ impl Iterator<Path> for Directories {
697697
///
698698
/// # Error
699699
///
700-
/// This function will return an `Err` value if an error happens, see
701-
/// `fs::mkdir` for more information about error conditions and performance.
700+
/// See `fs::mkdir`.
702701
pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> {
703702
// tjc: if directory exists but with different permissions,
704703
// should we return false?
@@ -735,8 +734,7 @@ pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> {
735734
///
736735
/// # Error
737736
///
738-
/// This function will return an `Err` value if an error happens. See
739-
/// `file::unlink` and `fs::readdir` for possible error conditions.
737+
/// See `file::unlink` and `fs::readdir`
740738
pub fn rmdir_recursive(path: &Path) -> IoResult<()> {
741739
let mut rm_stack = Vec::new();
742740
rm_stack.push(path.clone());

0 commit comments

Comments
 (0)