]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
utils: Return plain drive letter as base/pathname for drive letters on Windows
authorMartin Willi <martin@revosec.ch>
Fri, 7 Mar 2014 13:16:50 +0000 (14:16 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 4 Jun 2014 13:53:08 +0000 (15:53 +0200)
src/libstrongswan/utils/utils.c

index 1b3765a6937604a7d99be49bf8a5f387c8132aab..2829aba77f1bcfe2cb08e8290816a2a0a9ea32cb 100644 (file)
@@ -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])