diff options
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/vdir.h')
-rw-r--r-- | systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/vdir.h | 720 |
1 files changed, 360 insertions, 360 deletions
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/vdir.h b/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/vdir.h index c21ec7c400..f06830af41 100644 --- a/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/vdir.h +++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/vdir.h @@ -34,25 +34,25 @@ public: inline char* GetCurrentDirectoryA(int dwBufSize, char *lpBuffer) { - char* ptr = dirTableA[nDefault]; - while (--dwBufSize) - { - if ((*lpBuffer++ = *ptr++) == '\0') - break; - } + char* ptr = dirTableA[nDefault]; + while (--dwBufSize) + { + if ((*lpBuffer++ = *ptr++) == '\0') + break; + } *lpBuffer = '\0'; - return /* unused */ NULL; + return /* unused */ NULL; }; inline WCHAR* GetCurrentDirectoryW(int dwBufSize, WCHAR *lpBuffer) { - WCHAR* ptr = dirTableW[nDefault]; - while (--dwBufSize) - { - if ((*lpBuffer++ = *ptr++) == '\0') - break; - } + WCHAR* ptr = dirTableW[nDefault]; + while (--dwBufSize) + { + if ((*lpBuffer++ = *ptr++) == '\0') + break; + } *lpBuffer = '\0'; - return /* unused */ NULL; + return /* unused */ NULL; }; DWORD CalculateEnvironmentSpace(void); @@ -66,54 +66,54 @@ protected: inline const char *GetDefaultDirA(void) { - return dirTableA[nDefault]; + return dirTableA[nDefault]; }; inline void SetDefaultDirA(char const *pPath, int index) { - SetDirA(pPath, index); - nDefault = index; + SetDirA(pPath, index); + nDefault = index; }; inline const WCHAR *GetDefaultDirW(void) { - return dirTableW[nDefault]; + return dirTableW[nDefault]; }; inline void SetDefaultDirW(WCHAR const *pPath, int index) { - SetDirW(pPath, index); - nDefault = index; + SetDirW(pPath, index); + nDefault = index; }; inline const char *GetDirA(int index) { - char *ptr = dirTableA[index]; - if (!ptr) { - /* simulate the existence of this drive */ - ptr = szLocalBufferA; - ptr[0] = 'A' + index; - ptr[1] = ':'; - ptr[2] = '\\'; - ptr[3] = 0; - } - return ptr; + char *ptr = dirTableA[index]; + if (!ptr) { + /* simulate the existence of this drive */ + ptr = szLocalBufferA; + ptr[0] = 'A' + index; + ptr[1] = ':'; + ptr[2] = '\\'; + ptr[3] = 0; + } + return ptr; }; inline const WCHAR *GetDirW(int index) { - WCHAR *ptr = dirTableW[index]; - if (!ptr) { - /* simulate the existence of this drive */ - ptr = szLocalBufferW; - ptr[0] = 'A' + index; - ptr[1] = ':'; - ptr[2] = '\\'; - ptr[3] = 0; - } - return ptr; + WCHAR *ptr = dirTableW[index]; + if (!ptr) { + /* simulate the existence of this drive */ + ptr = szLocalBufferW; + ptr[0] = 'A' + index; + ptr[1] = ':'; + ptr[2] = '\\'; + ptr[3] = 0; + } + return ptr; }; inline int DriveIndex(char chr) { - if (chr == '\\' || chr == '/') - return ('Z'-'A')+1; - return (chr | 0x20)-'a'; + if (chr == '\\' || chr == '/') + return ('Z'-'A')+1; + return (chr | 0x20)-'a'; }; VMem *pMem; @@ -139,16 +139,16 @@ void VDir::Init(VDir* pDir, VMem *p) pMem = p; if (pDir) { - for (index = 0; index < driveCount; ++index) { - SetDirW(pDir->GetDirW(index), index); - } - nDefault = pDir->GetDefault(); + for (index = 0; index < driveCount; ++index) { + SetDirW(pDir->GetDirW(index), index); + } + nDefault = pDir->GetDefault(); } else { - int bSave = bManageDirectory; - DWORD driveBits = GetLogicalDrives(); + int bSave = bManageDirectory; + DWORD driveBits = GetLogicalDrives(); - bManageDirectory = 0; + bManageDirectory = 0; WCHAR szBuffer[MAX_PATH*driveCount]; if (GetLogicalDriveStringsW(sizeof(szBuffer), szBuffer)) { WCHAR* pEnv = GetEnvironmentStringsW(); @@ -162,7 +162,7 @@ void VDir::Init(VDir* pDir, VMem *p) FreeEnvironmentStringsW(pEnv); } SetDefaultW(L"."); - bManageDirectory = bSave; + bManageDirectory = bSave; } } @@ -172,30 +172,30 @@ int VDir::SetDirA(char const *pPath, int index) int length = 0; WCHAR wBuffer[MAX_PATH+1]; if (index < driveCount && pPath != NULL) { - length = strlen(pPath); - pMem->Free(dirTableA[index]); - ptr = dirTableA[index] = (char*)pMem->Malloc(length+2); - if (ptr != NULL) { - strcpy(ptr, pPath); - ptr += length-1; - chr = *ptr++; - if (chr != '\\' && chr != '/') { - *ptr++ = '\\'; - *ptr = '\0'; - } - MultiByteToWideChar(CP_ACP, 0, dirTableA[index], -1, - wBuffer, (sizeof(wBuffer)/sizeof(WCHAR))); - length = wcslen(wBuffer); - pMem->Free(dirTableW[index]); - dirTableW[index] = (WCHAR*)pMem->Malloc((length+1)*2); - if (dirTableW[index] != NULL) { - wcscpy(dirTableW[index], wBuffer); - } - } + length = strlen(pPath); + pMem->Free(dirTableA[index]); + ptr = dirTableA[index] = (char*)pMem->Malloc(length+2); + if (ptr != NULL) { + strcpy(ptr, pPath); + ptr += length-1; + chr = *ptr++; + if (chr != '\\' && chr != '/') { + *ptr++ = '\\'; + *ptr = '\0'; + } + MultiByteToWideChar(CP_ACP, 0, dirTableA[index], -1, + wBuffer, (sizeof(wBuffer)/sizeof(WCHAR))); + length = wcslen(wBuffer); + pMem->Free(dirTableW[index]); + dirTableW[index] = (WCHAR*)pMem->Malloc((length+1)*2); + if (dirTableW[index] != NULL) { + wcscpy(dirTableW[index], wBuffer); + } + } } if(bManageDirectory) - ::SetCurrentDirectoryA(pPath); + ::SetCurrentDirectoryA(pPath); return length; } @@ -203,26 +203,26 @@ int VDir::SetDirA(char const *pPath, int index) void VDir::FromEnvA(char *pEnv, int index) { /* gets the directory for index from the environment variable. */ while (*pEnv != '\0') { - if ((pEnv[0] == '=') && (DriveIndex(pEnv[1]) == index) + if ((pEnv[0] == '=') && (DriveIndex(pEnv[1]) == index) && pEnv[2] == ':' && pEnv[3] == '=') { - SetDirA(&pEnv[4], index); - break; - } - else - pEnv += strlen(pEnv)+1; + SetDirA(&pEnv[4], index); + break; + } + else + pEnv += strlen(pEnv)+1; } } void VDir::FromEnvW(WCHAR *pEnv, int index) { /* gets the directory for index from the environment variable. */ while (*pEnv != '\0') { - if ((pEnv[0] == '=') && (DriveIndex((char)pEnv[1]) == index) + if ((pEnv[0] == '=') && (DriveIndex((char)pEnv[1]) == index) && pEnv[2] == ':' && pEnv[3] == '=') { - SetDirW(&pEnv[4], index); - break; - } - else - pEnv += wcslen(pEnv)+1; + SetDirW(&pEnv[4], index); + break; + } + else + pEnv += wcslen(pEnv)+1; } } @@ -233,9 +233,9 @@ void VDir::SetDefaultA(char const *pDefault) if (GetFullPathNameA(pDefault, sizeof(szBuffer), szBuffer, &pPtr)) { if (*pDefault != '.' && pPtr != NULL) - *pPtr = '\0'; + *pPtr = '\0'; - SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0])); + SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0])); } } @@ -244,31 +244,31 @@ int VDir::SetDirW(WCHAR const *pPath, int index) WCHAR chr, *ptr; int length = 0; if (index < driveCount && pPath != NULL) { - length = wcslen(pPath); - pMem->Free(dirTableW[index]); - ptr = dirTableW[index] = (WCHAR*)pMem->Malloc((length+2)*2); - if (ptr != NULL) { + length = wcslen(pPath); + pMem->Free(dirTableW[index]); + ptr = dirTableW[index] = (WCHAR*)pMem->Malloc((length+2)*2); + if (ptr != NULL) { char *ansi; - wcscpy(ptr, pPath); - ptr += length-1; - chr = *ptr++; - if (chr != '\\' && chr != '/') { - *ptr++ = '\\'; - *ptr = '\0'; - } + wcscpy(ptr, pPath); + ptr += length-1; + chr = *ptr++; + if (chr != '\\' && chr != '/') { + *ptr++ = '\\'; + *ptr = '\0'; + } ansi = win32_ansipath(dirTableW[index]); - length = strlen(ansi); - pMem->Free(dirTableA[index]); - dirTableA[index] = (char*)pMem->Malloc(length+1); - if (dirTableA[index] != NULL) { - strcpy(dirTableA[index], ansi); - } + length = strlen(ansi); + pMem->Free(dirTableA[index]); + dirTableA[index] = (char*)pMem->Malloc(length+1); + if (dirTableA[index] != NULL) { + strcpy(dirTableA[index], ansi); + } win32_free(ansi); - } + } } if(bManageDirectory) - ::SetCurrentDirectoryW(pPath); + ::SetCurrentDirectoryW(pPath); return length; } @@ -280,9 +280,9 @@ void VDir::SetDefaultW(WCHAR const *pDefault) if (GetFullPathNameW(pDefault, (sizeof(szBuffer)/sizeof(WCHAR)), szBuffer, &pPtr)) { if (*pDefault != '.' && pPtr != NULL) - *pPtr = '\0'; + *pPtr = '\0'; - SetDefaultDirW(szBuffer, DriveIndex((char)szBuffer[0])); + SetDefaultDirW(szBuffer, DriveIndex((char)szBuffer[0])); } } @@ -314,69 +314,69 @@ inline bool IsSpecialFileName(const char* pName) char ch = (pName[0] & ~0x20); switch (ch) { - case 'A': /* AUX */ - if (((pName[1] & ~0x20) == 'U') - && ((pName[2] & ~0x20) == 'X') - && !pName[3]) - return true; - break; - case 'C': /* CLOCK$, COMx, CON, CONIN$ CONOUT$ */ - ch = (pName[1] & ~0x20); - switch (ch) - { - case 'L': /* CLOCK$ */ - if (((pName[2] & ~0x20) == 'O') - && ((pName[3] & ~0x20) == 'C') - && ((pName[4] & ~0x20) == 'K') - && (pName[5] == '$') - && !pName[6]) - return true; - break; - case 'O': /* COMx, CON, CONIN$ CONOUT$ */ - if ((pName[2] & ~0x20) == 'M') { - if ( inRANGE(pName[3], '1', '9') - && !pName[4]) - return true; - } - else if ((pName[2] & ~0x20) == 'N') { - if (!pName[3]) - return true; - else if ((pName[3] & ~0x20) == 'I') { - if (((pName[4] & ~0x20) == 'N') - && (pName[5] == '$') - && !pName[6]) - return true; - } - else if ((pName[3] & ~0x20) == 'O') { - if (((pName[4] & ~0x20) == 'U') - && ((pName[5] & ~0x20) == 'T') - && (pName[6] == '$') - && !pName[7]) - return true; - } - } - break; - } - break; - case 'L': /* LPTx */ - if (((pName[1] & ~0x20) == 'U') - && ((pName[2] & ~0x20) == 'X') - && inRANGE(pName[3], '1', '9') - && !pName[4]) - return true; - break; - case 'N': /* NUL */ - if (((pName[1] & ~0x20) == 'U') - && ((pName[2] & ~0x20) == 'L') - && !pName[3]) - return true; - break; - case 'P': /* PRN */ - if (((pName[1] & ~0x20) == 'R') - && ((pName[2] & ~0x20) == 'N') - && !pName[3]) - return true; - break; + case 'A': /* AUX */ + if (((pName[1] & ~0x20) == 'U') + && ((pName[2] & ~0x20) == 'X') + && !pName[3]) + return true; + break; + case 'C': /* CLOCK$, COMx, CON, CONIN$ CONOUT$ */ + ch = (pName[1] & ~0x20); + switch (ch) + { + case 'L': /* CLOCK$ */ + if (((pName[2] & ~0x20) == 'O') + && ((pName[3] & ~0x20) == 'C') + && ((pName[4] & ~0x20) == 'K') + && (pName[5] == '$') + && !pName[6]) + return true; + break; + case 'O': /* COMx, CON, CONIN$ CONOUT$ */ + if ((pName[2] & ~0x20) == 'M') { + if ( inRANGE(pName[3], '1', '9') + && !pName[4]) + return true; + } + else if ((pName[2] & ~0x20) == 'N') { + if (!pName[3]) + return true; + else if ((pName[3] & ~0x20) == 'I') { + if (((pName[4] & ~0x20) == 'N') + && (pName[5] == '$') + && !pName[6]) + return true; + } + else if ((pName[3] & ~0x20) == 'O') { + if (((pName[4] & ~0x20) == 'U') + && ((pName[5] & ~0x20) == 'T') + && (pName[6] == '$') + && !pName[7]) + return true; + } + } + break; + } + break; + case 'L': /* LPTx */ + if (((pName[1] & ~0x20) == 'U') + && ((pName[2] & ~0x20) == 'X') + && inRANGE(pName[3], '1', '9') + && !pName[4]) + return true; + break; + case 'N': /* NUL */ + if (((pName[1] & ~0x20) == 'U') + && ((pName[2] & ~0x20) == 'L') + && !pName[3]) + return true; + break; + case 'P': /* PRN */ + if (((pName[1] & ~0x20) == 'R') + && ((pName[2] & ~0x20) == 'N') + && !pName[3]) + return true; + break; } return false; } @@ -392,66 +392,66 @@ char *VDir::MapPathA(const char *pInName) int length = strlen(pInName); if (!length) - return (char*)pInName; + return (char*)pInName; if (length > MAX_PATH) { - strncpy(szlBuf, pInName, MAX_PATH); - if (IsPathSep(pInName[0]) && !IsPathSep(pInName[1])) { - /* absolute path - reduce length by 2 for drive specifier */ - szlBuf[MAX_PATH-2] = '\0'; - } - else - szlBuf[MAX_PATH] = '\0'; - pInName = szlBuf; + strncpy(szlBuf, pInName, MAX_PATH); + if (IsPathSep(pInName[0]) && !IsPathSep(pInName[1])) { + /* absolute path - reduce length by 2 for drive specifier */ + szlBuf[MAX_PATH-2] = '\0'; + } + else + szlBuf[MAX_PATH] = '\0'; + pInName = szlBuf; } /* strlen(pInName) is now <= MAX_PATH */ if (length > 1 && pInName[1] == ':') { - /* has drive letter */ - if (length > 2 && IsPathSep(pInName[2])) { - /* absolute with drive letter */ - DoGetFullPathNameA((char*)pInName, sizeof(szLocalBufferA), szLocalBufferA); - } - else { - /* relative path with drive letter */ + /* has drive letter */ + if (length > 2 && IsPathSep(pInName[2])) { + /* absolute with drive letter */ + DoGetFullPathNameA((char*)pInName, sizeof(szLocalBufferA), szLocalBufferA); + } + else { + /* relative path with drive letter */ driveIndex = DriveIndex(*pInName); if (driveIndex < 0 || driveIndex >= driveLetterCount) return (char *)pInName; - strcpy(szBuffer, GetDirA(driveIndex)); - strcat(szBuffer, &pInName[2]); - if(strlen(szBuffer) > MAX_PATH) - szBuffer[MAX_PATH] = '\0'; + strcpy(szBuffer, GetDirA(driveIndex)); + strcat(szBuffer, &pInName[2]); + if(strlen(szBuffer) > MAX_PATH) + szBuffer[MAX_PATH] = '\0'; - DoGetFullPathNameA(szBuffer, sizeof(szLocalBufferA), szLocalBufferA); - } + DoGetFullPathNameA(szBuffer, sizeof(szLocalBufferA), szLocalBufferA); + } } else { - /* no drive letter */ - if (length > 1 && IsPathSep(pInName[1]) && IsPathSep(pInName[0])) { - /* UNC name */ - DoGetFullPathNameA((char*)pInName, sizeof(szLocalBufferA), szLocalBufferA); - } - else { - strcpy(szBuffer, GetDefaultDirA()); - if (IsPathSep(pInName[0])) { - /* absolute path */ - strcpy(&szBuffer[2], pInName); - DoGetFullPathNameA(szBuffer, sizeof(szLocalBufferA), szLocalBufferA); - } - else { - /* relative path */ - if (IsSpecialFileName(pInName)) { - return (char*)pInName; - } - else { - strcat(szBuffer, pInName); - if (strlen(szBuffer) > MAX_PATH) - szBuffer[MAX_PATH] = '\0'; - - DoGetFullPathNameA(szBuffer, sizeof(szLocalBufferA), szLocalBufferA); - } - } - } + /* no drive letter */ + if (length > 1 && IsPathSep(pInName[1]) && IsPathSep(pInName[0])) { + /* UNC name */ + DoGetFullPathNameA((char*)pInName, sizeof(szLocalBufferA), szLocalBufferA); + } + else { + strcpy(szBuffer, GetDefaultDirA()); + if (IsPathSep(pInName[0])) { + /* absolute path */ + strcpy(&szBuffer[2], pInName); + DoGetFullPathNameA(szBuffer, sizeof(szLocalBufferA), szLocalBufferA); + } + else { + /* relative path */ + if (IsSpecialFileName(pInName)) { + return (char*)pInName; + } + else { + strcat(szBuffer, pInName); + if (strlen(szBuffer) > MAX_PATH) + szBuffer[MAX_PATH] = '\0'; + + DoGetFullPathNameA(szBuffer, sizeof(szLocalBufferA), szLocalBufferA); + } + } + } } return szLocalBufferA; @@ -465,17 +465,17 @@ int VDir::SetCurrentDirectoryA(char *lpBuffer) pPtr = MapPathA(lpBuffer); length = strlen(pPtr); if(length > 3 && IsPathSep(pPtr[length-1])) { - /* don't remove the trailing slash from 'x:\' */ - pPtr[length-1] = '\0'; + /* don't remove the trailing slash from 'x:\' */ + pPtr[length-1] = '\0'; } DWORD r = GetFileAttributesA(pPtr); if ((r != 0xffffffff) && (r & FILE_ATTRIBUTE_DIRECTORY)) { - char szBuffer[(MAX_PATH+1)*2]; - DoGetFullPathNameA(pPtr, sizeof(szBuffer), szBuffer); - SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0])); - nRet = 0; + char szBuffer[(MAX_PATH+1)*2]; + DoGetFullPathNameA(pPtr, sizeof(szBuffer), szBuffer); + SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0])); + nRet = 0; } return nRet; @@ -486,9 +486,9 @@ DWORD VDir::CalculateEnvironmentSpace(void) int index; DWORD dwSize = 0; for (index = 0; index < driveCount; ++index) { - if (dirTableA[index] != NULL) { - dwSize += strlen(dirTableA[index]) + 5; /* add 1 for trailing NULL and 4 for '=D:=' */ - } + if (dirTableA[index] != NULL) { + dwSize += strlen(dirTableA[index]) + 5; /* add 1 for trailing NULL and 4 for '=D:=' */ + } } return dwSize; } @@ -498,22 +498,22 @@ LPSTR VDir::BuildEnvironmentSpace(LPSTR lpStr) 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] = '\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; - } - } + lpDirStr = dirTableA[index]; + if (lpDirStr != NULL) { + lpStr[0] = '='; + lpStr[1] = lpDirStr[0]; + 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; } @@ -546,69 +546,69 @@ inline bool IsSpecialFileName(const WCHAR* pName) WCHAR ch = (pName[0] & ~0x20); switch (ch) { - case 'A': /* AUX */ - if (((pName[1] & ~0x20) == 'U') - && ((pName[2] & ~0x20) == 'X') - && !pName[3]) - return true; - break; - case 'C': /* CLOCK$, COMx, CON, CONIN$ CONOUT$ */ - ch = (pName[1] & ~0x20); - switch (ch) - { - case 'L': /* CLOCK$ */ - if (((pName[2] & ~0x20) == 'O') - && ((pName[3] & ~0x20) == 'C') - && ((pName[4] & ~0x20) == 'K') - && (pName[5] == '$') - && !pName[6]) - return true; - break; - case 'O': /* COMx, CON, CONIN$ CONOUT$ */ - if ((pName[2] & ~0x20) == 'M') { - if ( inRANGE(pName[3], '1', '9') - && !pName[4]) - return true; - } - else if ((pName[2] & ~0x20) == 'N') { - if (!pName[3]) - return true; - else if ((pName[3] & ~0x20) == 'I') { - if (((pName[4] & ~0x20) == 'N') - && (pName[5] == '$') - && !pName[6]) - return true; - } - else if ((pName[3] & ~0x20) == 'O') { - if (((pName[4] & ~0x20) == 'U') - && ((pName[5] & ~0x20) == 'T') - && (pName[6] == '$') - && !pName[7]) - return true; - } - } - break; - } - break; - case 'L': /* LPTx */ - if (((pName[1] & ~0x20) == 'U') - && ((pName[2] & ~0x20) == 'X') - && inRANGE(pName[3], '1', '9') - && !pName[4]) - return true; - break; - case 'N': /* NUL */ - if (((pName[1] & ~0x20) == 'U') - && ((pName[2] & ~0x20) == 'L') - && !pName[3]) - return true; - break; - case 'P': /* PRN */ - if (((pName[1] & ~0x20) == 'R') - && ((pName[2] & ~0x20) == 'N') - && !pName[3]) - return true; - break; + case 'A': /* AUX */ + if (((pName[1] & ~0x20) == 'U') + && ((pName[2] & ~0x20) == 'X') + && !pName[3]) + return true; + break; + case 'C': /* CLOCK$, COMx, CON, CONIN$ CONOUT$ */ + ch = (pName[1] & ~0x20); + switch (ch) + { + case 'L': /* CLOCK$ */ + if (((pName[2] & ~0x20) == 'O') + && ((pName[3] & ~0x20) == 'C') + && ((pName[4] & ~0x20) == 'K') + && (pName[5] == '$') + && !pName[6]) + return true; + break; + case 'O': /* COMx, CON, CONIN$ CONOUT$ */ + if ((pName[2] & ~0x20) == 'M') { + if ( inRANGE(pName[3], '1', '9') + && !pName[4]) + return true; + } + else if ((pName[2] & ~0x20) == 'N') { + if (!pName[3]) + return true; + else if ((pName[3] & ~0x20) == 'I') { + if (((pName[4] & ~0x20) == 'N') + && (pName[5] == '$') + && !pName[6]) + return true; + } + else if ((pName[3] & ~0x20) == 'O') { + if (((pName[4] & ~0x20) == 'U') + && ((pName[5] & ~0x20) == 'T') + && (pName[6] == '$') + && !pName[7]) + return true; + } + } + break; + } + break; + case 'L': /* LPTx */ + if (((pName[1] & ~0x20) == 'U') + && ((pName[2] & ~0x20) == 'X') + && inRANGE(pName[3], '1', '9') + && !pName[4]) + return true; + break; + case 'N': /* NUL */ + if (((pName[1] & ~0x20) == 'U') + && ((pName[2] & ~0x20) == 'L') + && !pName[3]) + return true; + break; + case 'P': /* PRN */ + if (((pName[1] & ~0x20) == 'R') + && ((pName[2] & ~0x20) == 'N') + && !pName[3]) + return true; + break; } return false; } @@ -624,66 +624,66 @@ WCHAR* VDir::MapPathW(const WCHAR *pInName) int length = wcslen(pInName); if (!length) - return (WCHAR*)pInName; + return (WCHAR*)pInName; if (length > MAX_PATH) { - wcsncpy(szlBuf, pInName, MAX_PATH); - if (IsPathSep(pInName[0]) && !IsPathSep(pInName[1])) { - /* absolute path - reduce length by 2 for drive specifier */ - szlBuf[MAX_PATH-2] = '\0'; - } - else - szlBuf[MAX_PATH] = '\0'; - pInName = szlBuf; + wcsncpy(szlBuf, pInName, MAX_PATH); + if (IsPathSep(pInName[0]) && !IsPathSep(pInName[1])) { + /* absolute path - reduce length by 2 for drive specifier */ + szlBuf[MAX_PATH-2] = '\0'; + } + else + szlBuf[MAX_PATH] = '\0'; + pInName = szlBuf; } /* strlen(pInName) is now <= MAX_PATH */ if (length > 1 && pInName[1] == ':') { - /* has drive letter */ - if (IsPathSep(pInName[2])) { - /* absolute with drive letter */ - DoGetFullPathNameW((WCHAR*)pInName, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); - } - else { - /* relative path with drive letter */ + /* has drive letter */ + if (IsPathSep(pInName[2])) { + /* absolute with drive letter */ + DoGetFullPathNameW((WCHAR*)pInName, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); + } + else { + /* relative path with drive letter */ driveIndex = DriveIndex(*pInName); if (driveIndex < 0 || driveIndex >= driveLetterCount) return (WCHAR *)pInName; - wcscpy(szBuffer, GetDirW(driveIndex)); - wcscat(szBuffer, &pInName[2]); - if(wcslen(szBuffer) > MAX_PATH) - szBuffer[MAX_PATH] = '\0'; + wcscpy(szBuffer, GetDirW(driveIndex)); + wcscat(szBuffer, &pInName[2]); + if(wcslen(szBuffer) > MAX_PATH) + szBuffer[MAX_PATH] = '\0'; - DoGetFullPathNameW(szBuffer, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); - } + DoGetFullPathNameW(szBuffer, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); + } } else { - /* no drive letter */ - if (length > 1 && IsPathSep(pInName[1]) && IsPathSep(pInName[0])) { - /* UNC name */ - DoGetFullPathNameW((WCHAR*)pInName, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); - } - else { - wcscpy(szBuffer, GetDefaultDirW()); - if (IsPathSep(pInName[0])) { - /* absolute path */ - wcscpy(&szBuffer[2], pInName); - DoGetFullPathNameW(szBuffer, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); - } - else { - /* relative path */ - if (IsSpecialFileName(pInName)) { - return (WCHAR*)pInName; - } - else { - wcscat(szBuffer, pInName); - if (wcslen(szBuffer) > MAX_PATH) - szBuffer[MAX_PATH] = '\0'; - - DoGetFullPathNameW(szBuffer, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); - } - } - } + /* no drive letter */ + if (length > 1 && IsPathSep(pInName[1]) && IsPathSep(pInName[0])) { + /* UNC name */ + DoGetFullPathNameW((WCHAR*)pInName, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); + } + else { + wcscpy(szBuffer, GetDefaultDirW()); + if (IsPathSep(pInName[0])) { + /* absolute path */ + wcscpy(&szBuffer[2], pInName); + DoGetFullPathNameW(szBuffer, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); + } + else { + /* relative path */ + if (IsSpecialFileName(pInName)) { + return (WCHAR*)pInName; + } + else { + wcscat(szBuffer, pInName); + if (wcslen(szBuffer) > MAX_PATH) + szBuffer[MAX_PATH] = '\0'; + + DoGetFullPathNameW(szBuffer, (sizeof(szLocalBufferW)/sizeof(WCHAR)), szLocalBufferW); + } + } + } } return szLocalBufferW; } @@ -696,17 +696,17 @@ int VDir::SetCurrentDirectoryW(WCHAR *lpBuffer) pPtr = MapPathW(lpBuffer); length = wcslen(pPtr); if(length > 3 && IsPathSep(pPtr[length-1])) { - /* don't remove the trailing slash from 'x:\' */ - pPtr[length-1] = '\0'; + /* don't remove the trailing slash from 'x:\' */ + pPtr[length-1] = '\0'; } DWORD r = GetFileAttributesW(pPtr); if ((r != 0xffffffff) && (r & FILE_ATTRIBUTE_DIRECTORY)) { - WCHAR wBuffer[(MAX_PATH+1)*2]; - DoGetFullPathNameW(pPtr, (sizeof(wBuffer)/sizeof(WCHAR)), wBuffer); - SetDefaultDirW(wBuffer, DriveIndex((char)wBuffer[0])); - nRet = 0; + WCHAR wBuffer[(MAX_PATH+1)*2]; + DoGetFullPathNameW(pPtr, (sizeof(wBuffer)/sizeof(WCHAR)), wBuffer); + SetDefaultDirW(wBuffer, DriveIndex((char)wBuffer[0])); + nRet = 0; } return nRet; |