From e22f42334d95c48dd04524736de12d74ee77cf2a Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Sun, 16 Sep 2012 14:15:49 -0500 Subject: [PATCH] FS-4099 --resolve switch windows to use posix delimiter (/) for base paths. This will correct numerous problems with escaped chars. This change only effects windows builds. Please test. --- src/include/switch_types.h | 2 +- src/switch_core.c | 4 ++++ src/switch_xml.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 088050f86a..9ddadd1a3e 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -113,7 +113,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_MAX_DTMF_DURATION 192000 #define SWITCH_DEFAULT_DIR_PERMS SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_UEXECUTE | SWITCH_FPROT_GREAD | SWITCH_FPROT_GEXECUTE #ifdef WIN32 -#define SWITCH_PATH_SEPARATOR "\\" +#define SWITCH_PATH_SEPARATOR "/" #else #define SWITCH_PATH_SEPARATOR "/" #endif diff --git a/src/switch_core.c b/src/switch_core.c index 3f1a6d5075..53bd4b8762 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -520,12 +520,16 @@ SWITCH_DECLARE(void) switch_core_set_globals(void) DWORD dwBufSize = BUFSIZE; char base_dir[1024]; char *lastbacklash; + char *tmp; GetModuleFileName(NULL, base_dir, BUFSIZE); lastbacklash = strrchr(base_dir, '\\'); base_dir[(lastbacklash - base_dir)] = '\0'; /* set base_dir as cwd, to be able to use relative paths in scripting languages (e.g. mod_lua) when FS is running as a service or while debugging FS using visual studio */ SetCurrentDirectory(base_dir); + tmp = switch_string_replace(base_dir, "\\", "/"); + strcpy(base_dir, tmp); + free(tmp); #else char base_dir[1024] = SWITCH_PREFIX_DIR; diff --git a/src/switch_xml.c b/src/switch_xml.c index 585b867995..95a51c39e8 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -3076,7 +3076,7 @@ done: #define RANGE '-' #define RBRACKET ']' #define SEP '/' -#define WIN_SEP '\\' +#define WIN_SEP '/' #define STAR '*' #define TILDE '~' #define UNDERSCORE '_'