From 8681ac764a7d8532edbd724ebb23e6a2500c3b67 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Wed, 3 Sep 2003 02:59:30 +0000 Subject: [PATCH] Fixed problems with Windows path which include a drive letter. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1187 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/file/dirs.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sc2/src/sc2code/libs/file/dirs.c b/sc2/src/sc2code/libs/file/dirs.c index 398c1b213..5b11015c4 100644 --- a/sc2/src/sc2code/libs/file/dirs.c +++ b/sc2/src/sc2code/libs/file/dirs.c @@ -39,8 +39,8 @@ #define APPDATA_FALLBACK -static char *expandPathAbsolute (char *dest, size_t destLen, char first, - int what); +static char *expandPathAbsolute (char *dest, size_t destLen, + const char *src, int what); int @@ -210,7 +210,7 @@ expandPath (char *dest, size_t len, const char *src, int what) if (what & EP_ABSOLUTE) { dest = expandPathAbsolute (dest, destend - dest, - home[0], what); + home, what); if (dest == NULL) { // errno is set @@ -230,7 +230,7 @@ expandPath (char *dest, size_t len, const char *src, int what) if (what & EP_ABSOLUTE) { - destptr = expandPathAbsolute (destptr, destend - destptr, src[0], + destptr = expandPathAbsolute (destptr, destend - destptr, src, what); if (destptr == NULL) { @@ -362,9 +362,13 @@ expandPath (char *dest, size_t len, const char *src, int what) // helper for expandPath, expanding an absolute path // returns a pointer to the end of the filled in part of dest. static char * -expandPathAbsolute (char *dest, size_t destLen, char first, int what) +expandPathAbsolute (char *dest, size_t destLen, const char *src, int what) { - if (first == '/' || ((what & EP_SLASHES) && first == '\\')) { + if (src[0] == '/' || ((what & EP_SLASHES) && src[0] == '\\') +#ifdef WIN32 + || (isalpha(src[0]) && (src[1] == ':')) +#endif + ) { // Path is already absolute; nothing to do return dest; }