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
This commit is contained in:
meep-eep
2003-09-03 02:59:30 +00:00
parent 37f22ae10e
commit 8681ac764a
+10 -6
View File
@@ -39,8 +39,8 @@
#define APPDATA_FALLBACK #define APPDATA_FALLBACK
static char *expandPathAbsolute (char *dest, size_t destLen, char first, static char *expandPathAbsolute (char *dest, size_t destLen,
int what); const char *src, int what);
int int
@@ -210,7 +210,7 @@ expandPath (char *dest, size_t len, const char *src, int what)
if (what & EP_ABSOLUTE) { if (what & EP_ABSOLUTE) {
dest = expandPathAbsolute (dest, destend - dest, dest = expandPathAbsolute (dest, destend - dest,
home[0], what); home, what);
if (dest == NULL) if (dest == NULL)
{ {
// errno is set // errno is set
@@ -230,7 +230,7 @@ expandPath (char *dest, size_t len, const char *src, int what)
if (what & EP_ABSOLUTE) if (what & EP_ABSOLUTE)
{ {
destptr = expandPathAbsolute (destptr, destend - destptr, src[0], destptr = expandPathAbsolute (destptr, destend - destptr, src,
what); what);
if (destptr == NULL) 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 // helper for expandPath, expanding an absolute path
// returns a pointer to the end of the filled in part of dest. // returns a pointer to the end of the filled in part of dest.
static char * 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 // Path is already absolute; nothing to do
return dest; return dest;
} }