/* has drive letter */
if (IsPathSep(pInName[2])) {
/* absolute with drive letter */
- strcpy(szLocalBufferA, pInName);
+ DoGetFullPathNameA((char*)pInName, sizeof(szLocalBufferA), szLocalBufferA);
}
else {
/* relative path with drive letter */
/* no drive letter */
if (IsPathSep(pInName[1]) && IsPathSep(pInName[0])) {
/* UNC name */
- strcpy(szLocalBufferA, pInName);
+ DoGetFullPathNameA((char*)pInName, sizeof(szLocalBufferA), szLocalBufferA);
}
else {
strcpy(szBuffer, GetDefaultDirA());
if (IsPathSep(pInName[0])) {
/* absolute path */
- szLocalBufferA[0] = szBuffer[0];
- szLocalBufferA[1] = szBuffer[1];
- strcpy(&szLocalBufferA[2], pInName);
+ strcpy(&szBuffer[2], pInName);
+ DoGetFullPathNameA(szBuffer, sizeof(szLocalBufferA), szLocalBufferA);
}
else {
/* relative path */
DWORD r = GetFileAttributesA(pPtr);
if ((r != 0xffffffff) && (r & FILE_ATTRIBUTE_DIRECTORY))
{
- SetDefaultDirA(pPtr, DriveIndex(pPtr[0]));
+ char szBuffer[(MAX_PATH+1)*2];
+ DoGetFullPathNameA(pPtr, sizeof(szBuffer), szBuffer);
+ SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0]));
nRet = 0;
}
}
DWORD VDir::CalculateEnvironmentSpace(void)
-{ /* the current directory environment strings are stored as '=d=d:\path' */
+{ /* the current directory environment strings are stored as '=D:=d:\path' */
int index;
DWORD dwSize = 0;
for (index = 0; index < driveCount; ++index) {
if (dirTableA[index] != NULL) {
- dwSize += strlen(dirTableA[index]) + 4; /* add 1 for trailing NULL and 3 for '=d=' */
+ dwSize += strlen(dirTableA[index]) + 5; /* add 1 for trailing NULL and 4 for '=D:=' */
}
}
return dwSize;
}
LPSTR VDir::BuildEnvironmentSpace(LPSTR lpStr)
-{ /* store the current directory environment strings as '=d=d:\path' */
- int index;
+{ /* store the current directory environment strings as '=D:=d:\path' */
+ int index, length;
LPSTR lpDirStr;
for (index = 0; index < driveCount; ++index) {
lpDirStr = dirTableA[index];
if (lpDirStr != NULL) {
lpStr[0] = '=';
lpStr[1] = lpDirStr[0];
- lpStr[2] = '=';
- strcpy(&lpStr[3], lpDirStr);
- lpStr += strlen(lpDirStr) + 4; /* add 1 for trailing NULL and 3 for '=d=' */
+ lpStr[2] = '\0';
+ CharUpper(&lpStr[1]);
+ lpStr[2] = ':';
+ lpStr[3] = '=';
+ strcpy(&lpStr[4], lpDirStr);
+ length = strlen(lpDirStr);
+ lpStr += length + 5; /* add 1 for trailing NULL and 4 for '=D:=' */
+ if (length > 3 && IsPathSep(lpStr[-2])) {
+ lpStr[-2] = '\0'; /* remove the trailing path separator */
+ --lpStr;
+ }
}
}
return lpStr;
/* has drive letter */
if (IsPathSep(pInName[2])) {
/* absolute with drive letter */
- wcscpy(szLocalBufferW, pInName);
+ DoGetFullPathNameW((WCHAR*)pInName, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW);
}
else {
/* relative path with drive letter */
/* no drive letter */
if (IsPathSep(pInName[1]) && IsPathSep(pInName[0])) {
/* UNC name */
- wcscpy(szLocalBufferW, pInName);
+ DoGetFullPathNameW((WCHAR*)pInName, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW);
}
else {
wcscpy(szBuffer, GetDefaultDirW());
if (IsPathSep(pInName[0])) {
/* absolute path */
- szLocalBufferW[0] = szBuffer[0];
- szLocalBufferW[1] = szBuffer[1];
- wcscpy(&szLocalBufferW[2], pInName);
+ wcscpy(&szBuffer[2], pInName);
+ DoGetFullPathNameW(szBuffer, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW);
}
else {
/* relative path */
DWORD r = GetFileAttributesW(pPtr);
if ((r != 0xffffffff) && (r & FILE_ATTRIBUTE_DIRECTORY))
{
- SetDefaultDirW(pPtr, DriveIndex((char)pPtr[0]));
+ WCHAR wBuffer[(MAX_PATH+1)*2];
+ DoGetFullPathNameW(pPtr, (sizeof(wBuffer)/sizeof(WCHAR)), wBuffer);
+ SetDefaultDirW(wBuffer, DriveIndex((char)wBuffer[0]));
nRet = 0;
}