aboutsummaryrefslogtreecommitdiff
path: root/libssh/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libssh/misc.c')
-rw-r--r--libssh/misc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libssh/misc.c b/libssh/misc.c
index 1359c156..b97b7e02 100644
--- a/libssh/misc.c
+++ b/libssh/misc.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include "config.h"
@@ -35,6 +36,7 @@
#define _WIN32_IE 0x0400 //SHGetSpecialFolderPath
#include <shlobj.h>
#include <winsock2.h>
+#include <direct.h>
#else
#include <pwd.h>
#include <arpa/inet.h>
@@ -258,5 +260,28 @@ char *ssh_basename (const char *path) {
return new;
}
+/**
+ * @brief Attempts to create a directory with the given pathname.
+ *
+ * This is the portable version of mkdir, mode is ignored on Windows systems.
+ *
+ * @param pathname The path name to create the directory.
+ *
+ * @param mode The permissions to use.
+ *
+ * @return 0 on success, < 0 on error with errno set.
+ */
+int ssh_mkdir(const char *pathname, mode_t mode) {
+ int r;
+
+#ifdef _WIN32
+ r = _mkdir(pathname);
+#else
+ r = mkdir(pathname, mode);
+#endif
+
+ return r;
+}
+
/** @} */
/* vim: set ts=2 sw=2 et cindent: */