From 32d52933181eede0a3dd753e39b34a6d1cfa0d18 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 9 Sep 2009 14:01:20 +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 1359c156..b97b7e02 100644 --- a/libssh/misc.c +++ b/libssh/misc.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "config.h" @@ -35,6 +36,7 @@ #define _WIN32_IE 0x0400 //SHGetSpecialFolderPath #include #include +#include #else #include #include @@ -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: */ -- cgit