about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-12-29 16:36:12 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-12-29 16:36:12 -0800
commit3801c2678fc1cffd310a36be86ac0a9b9d3a502d (patch)
tree9817b35aea7c21c047c395f35c0c9e8f791d6da9 /src/libstd/io
parentbcd3b1685ab8f0ed1ef2e78a9bc89afbdc5913eb (diff)
parenteb4b20288e6e8e704f5248c56601149dbf856599 (diff)
downloadrust-3801c2678fc1cffd310a36be86ac0a9b9d3a502d.tar.gz
rust-3801c2678fc1cffd310a36be86ac0a9b9d3a502d.zip
rollup merge of #20231: fhahn/issue-20226-eexist
I've created a patch for #20226, which maps `EEXIST` to the `PathAlreadyExists` error on Unix. To test this, I use `mkdir`, which raises `EEXIST` if the directory already exists.

On Windows, I map `ERROR_ALREADY_EXISTS` to `PathAlreadyExist`, but I am note sure if `mkdir` on Windows raises `ERROR_ALREADY_EXISTS` and do not have a Windows installation handy for testing.

And I noticed another thing. No error seems to map to `IoErrorKind::PathDoesntExist` and I am wondering what the difference to `FileNotFound` is?
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/fs.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs
index f2db2875ebf..caa6590bb28 100644
--- a/src/libstd/io/fs.rs
+++ b/src/libstd/io/fs.rs
@@ -1149,6 +1149,19 @@ mod test {
     }
 
     #[test]
+    fn mkdir_path_already_exists_error() {
+        use io::{IoError, PathAlreadyExists};
+
+        let tmpdir = tmpdir();
+        let dir = &tmpdir.join("mkdir_error_twice");
+        check!(mkdir(dir, io::USER_RWX));
+        match mkdir(dir, io::USER_RWX) {
+            Err(IoError{kind:PathAlreadyExists,..}) => (),
+            _ => assert!(false)
+        };
+    }
+
+    #[test]
     fn recursive_mkdir() {
         let tmpdir = tmpdir();
         let dir = tmpdir.join("d1/d2");