]> git.pond.sub.org Git - empserver/commitdiff
(set_dirs) [_WIN32]: Add the ability to deal with Windows
authorRon Koenderink <rkoenderink@yahoo.ca>
Tue, 21 Feb 2006 20:15:55 +0000 (20:15 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Tue, 21 Feb 2006 20:15:55 +0000 (20:15 +0000)
file and directory names.

src/lib/gen/emp_config.c

index f71024d835d0256ed2b7b80726cf55cf7ebf9f62..709975e5697ef1750fdd8b3d49a31890df056571 100644 (file)
@@ -48,6 +48,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef _WIN32
+#include <direct.h>
+#endif
 
 #include "misc.h"
 #include "file.h"
@@ -174,6 +177,13 @@ set_dirs(char *econfig)
     char *slash;
     char *cwd = getcwd(NULL, 0);
 
+#ifdef _WIN32
+    econfig = _fullpath(NULL, econfig, 0);
+    slash = strrchr(econfig, '\\');
+    configdir = malloc(slash - econfig + 1);
+    memcpy(configdir, econfig, slash - econfig);
+    configdir[slash - econfig] = 0;
+#else
     if ((slash = strrchr(econfig, '/'))) {
        configdir = malloc(slash - econfig + 1);
        memcpy(configdir, econfig, slash - econfig);
@@ -189,6 +199,7 @@ set_dirs(char *econfig)
        sprintf(configdir, "%s/%s", cwd, tmp);
        free(tmp);
     }
+#endif /* !_WIN32 */
 
     free(cwd);
 }