(set_dirs) [_WIN32]: Add the ability to deal with Windows
file and directory names.
This commit is contained in:
parent
783b00bbad
commit
2147583a9e
1 changed files with 11 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue