From 97b6036cbf3e444384a8e9b7f082e22d9ea64fe1 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 9 Sep 2009 13:42:00 +0200 Subject: Add a portable ssh_mkdir function for Windows. --- libssh/misc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libssh/misc.c') diff --git a/libssh/misc.c b/libssh/misc.c index 5fbd28e..1f977eb 100644 --- a/libssh/misc.c +++ b/libssh/misc.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "config.h" @@ -34,6 +35,7 @@ #define _WIN32_IE 0x0400 //SHGetSpecialFolderPath #include // Must be the first to include #include +#include #else #include #include @@ -347,5 +349,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: */ -- cgit