From 2496eaffdeb855624903950ba844bfdad6361891 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 7 Mar 2014 14:16:50 +0100 Subject: [PATCH] utils: Return plain drive letter as base/pathname for drive letters on Windows --- src/libstrongswan/utils/utils.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c index 1b3765a69..2829aba77 100644 --- a/src/libstrongswan/utils/utils.c +++ b/src/libstrongswan/utils/utils.c @@ -241,6 +241,15 @@ char* path_dirname(const char *path) } if (!pos) { +#ifdef WIN32 + if (path && strlen(path)) + { + if ((isalpha(path[0]) && path[1] == ':')) + { /* if just a drive letter given, return that as dirname */ + return chunk_clone(chunk_from_chars(path[0], ':', 0)).ptr; + } + } +#endif return strdup("."); } while (pos > path && *pos == DIRECTORY_SEPARATOR[0])