Handle paths of the form "d:foo/bar" on platforms which don't have a current working directory per drive.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3057 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -518,7 +518,12 @@ typedef unsigned int wint_t;
|
|||||||
// HAVE_UNC_PATHS is defined to signify that Universal Naming Convention
|
// HAVE_UNC_PATHS is defined to signify that Universal Naming Convention
|
||||||
// style paths are to be recognised on this platform.
|
// style paths are to be recognised on this platform.
|
||||||
# define HAVE_UNC_PATHS
|
# define HAVE_UNC_PATHS
|
||||||
|
// HAVE_CWD_PER_DRIVE is defined to signify that every drive has its own
|
||||||
|
// current working directory.
|
||||||
|
# define HAVE_CWD_PER_DRIVE
|
||||||
#endif
|
#endif
|
||||||
|
// REJECT_DRIVE_PATH_WITHOUT_SLASH can also be defined, if paths of the form
|
||||||
|
// "d:foo/bar" (without a slash after the drive letter) are to be rejected.
|
||||||
|
|
||||||
#endif /* _PORT_H */
|
#endif /* _PORT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -685,6 +685,13 @@ expandPathAbsolute (char *dest, size_t destLen, const char *src,
|
|||||||
// Path is of the form "d:path", without a (back)slash after the
|
// Path is of the form "d:path", without a (back)slash after the
|
||||||
// semicolon.
|
// semicolon.
|
||||||
|
|
||||||
|
#ifdef REJECT_DRIVE_PATH_WITHOUT_SLASH
|
||||||
|
// We reject paths of the form "d:foo/bar".
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
#elif defined(HAVE_CWD_PER_DRIVE)
|
||||||
|
// Paths of the form "d:foo/bar" are treated as "foo/bar" relative
|
||||||
|
// to the working directory of d:.
|
||||||
letter = tolower(src[0]) - 'a';
|
letter = tolower(src[0]) - 'a';
|
||||||
|
|
||||||
// _getdcwd() should only be called on drives that exist.
|
// _getdcwd() should only be called on drives that exist.
|
||||||
@@ -706,6 +713,19 @@ expandPathAbsolute (char *dest, size_t destLen, const char *src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
src += 2;
|
src += 2;
|
||||||
|
#else /* if !defined(HAVE_CWD_PER_DRIVE) */
|
||||||
|
// We treat paths of the form "d:foo/bar" as "d:/foo/bar".
|
||||||
|
if (destLen < 3) {
|
||||||
|
errno = ERANGE;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
dest[0] = src[0];
|
||||||
|
dest[1] = ':';
|
||||||
|
dest[2] = '/';
|
||||||
|
*skipSrc = 2;
|
||||||
|
dest += 3;
|
||||||
|
return dest;
|
||||||
|
#endif /* HAVE_CWD_PER_DRIVE */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* HAVE_DRIVE_LETTERS */
|
#endif /* HAVE_DRIVE_LETTERS */
|
||||||
|
|||||||
Reference in New Issue
Block a user