about summary refs log tree commit diff
path: root/src/libstd/fs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-03-16 18:08:57 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-03-19 09:59:21 -0700
commitdedac5eb3c657c39f9f328f303dc7ef01dd760c3 (patch)
tree11494f8adbbaa8e954cfb5635db07b8f26d46d9d /src/libstd/fs
parent12cb7c6a2847959460ecac75b2c983d071585472 (diff)
downloadrust-dedac5eb3c657c39f9f328f303dc7ef01dd760c3.tar.gz
rust-dedac5eb3c657c39f9f328f303dc7ef01dd760c3.zip
std: Stablize io::ErrorKind
This commit stabilizes the `ErrorKind` enumeration which is consumed by and
generated by the `io::Error` type. The purpose of this type is to serve as a
cross-platform namespace to categorize errors into. Two specific issues are
addressed as part of this stablization:

* The naming of each variant was scrutinized and some were tweaked. An example
  is how `FileNotFound` was renamed to simply `NotFound`. These names should not
  show either a Unix or Windows bias and the set of names is intended to grow
  over time. For now the names will likely largely consist of those errors
  generated by the I/O APIs in the standard library.

* The mapping of OS error codes onto kinds has been altered. Coalescing no
  longer occurs (multiple error codes become one kind). It is intended that each
  OS error code, if bound, corresponds to only one `ErrorKind`. The current set
  of error kinds was expanded slightly to include some networking errors.

This commit also adds a `raw_os_error` function which returns an `Option<i32>`
to extract the underlying raw error code from the `Error`.
Diffstat (limited to 'src/libstd/fs')
-rw-r--r--src/libstd/fs/mod.rs4
-rw-r--r--src/libstd/fs/tempdir.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/fs/mod.rs b/src/libstd/fs/mod.rs
index ba89b3a0ea6..80336a0da87 100644
--- a/src/libstd/fs/mod.rs
+++ b/src/libstd/fs/mod.rs
@@ -493,7 +493,7 @@ pub fn copy<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<u64> {
     let from = from.as_path();
     let to = to.as_path();
     if !from.is_file() {
-        return Err(Error::new(ErrorKind::MismatchedFileTypeForOperation,
+        return Err(Error::new(ErrorKind::InvalidInput,
                               "the source path is not an existing file",
                               None))
     }
@@ -1134,7 +1134,7 @@ mod tests {
         let dir = &tmpdir.join("mkdir_error_twice");
         check!(fs::create_dir(dir));
         let e = fs::create_dir(dir).err().unwrap();
-        assert_eq!(e.kind(), ErrorKind::PathAlreadyExists);
+        assert_eq!(e.kind(), ErrorKind::AlreadyExists);
     }
 
     #[test]
diff --git a/src/libstd/fs/tempdir.rs b/src/libstd/fs/tempdir.rs
index c1da77a6668..8f32d7a5864 100644
--- a/src/libstd/fs/tempdir.rs
+++ b/src/libstd/fs/tempdir.rs
@@ -68,12 +68,12 @@ impl TempDir {
             let path = tmpdir.join(&leaf);
             match fs::create_dir(&path) {
                 Ok(_) => return Ok(TempDir { path: Some(path) }),
-                Err(ref e) if e.kind() == ErrorKind::PathAlreadyExists => {}
+                Err(ref e) if e.kind() == ErrorKind::AlreadyExists => {}
                 Err(e) => return Err(e)
             }
         }
 
-        Err(Error::new(ErrorKind::PathAlreadyExists,
+        Err(Error::new(ErrorKind::AlreadyExists,
                        "too many temporary directories already exist",
                        None))
     }