]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - fd.c
fd: Revamp para_mkdir().
[paraslash.git] / fd.c
diff --git a/fd.c b/fd.c
index d858ae623ba6203719e70930625df97867166e67..917ed186a00182568c3aa6618ef54d771e59ea17 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -440,17 +440,23 @@ close_cwd:
 }
 
 /**
- * A wrapper for mkdir(2).
+ * Create a directory, don't fail if it already exists.
  *
  * \param path Name of the directory to create.
- * \param mode The permissions to use.
  *
- * \return Standard.
+ * This function passes the fixed mode value 0777 to mkdir(3) (which consults
+ * the file creation mask and restricts this value).
+ *
+ * \return Zero if the directory already existed, one if the directory has been
+ * created, negative error code if the mkdir(3) call failed for any reason
+ * other than EEXIST.
  */
-int para_mkdir(const char *path, mode_t mode)
+int para_mkdir(const char *path)
 {
-       if (!mkdir(path, mode))
+       if (mkdir(path, 0777) == 0)
                return 1;
+       if (errno == EEXIST)
+               return 0;
        return -ERRNO_TO_PARA_ERROR(errno);
 }