summaryrefslogtreecommitdiff
path: root/win32/vdir.h
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-12-20 17:18:23 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-12-20 17:18:23 +0000
commitfd9459bc435247011bdd5dc44ff2358cc4d1b124 (patch)
tree3eb6600af148acf31b4ceb9e885ca6d309613093 /win32/vdir.h
parentf8bca53996f55892ef15f2efd8c73aa499fb7417 (diff)
downloadperl-fd9459bc435247011bdd5dc44ff2358cc4d1b124.tar.gz
virtual directory handling broken on paths with trailing slash
p4raw-id: //depot/perl@4702
Diffstat (limited to 'win32/vdir.h')
-rw-r--r--win32/vdir.h63
1 files changed, 44 insertions, 19 deletions
diff --git a/win32/vdir.h b/win32/vdir.h
index 0d21616df1..a8a34e4f12 100644
--- a/win32/vdir.h
+++ b/win32/vdir.h
@@ -321,32 +321,27 @@ int VDir::SetCurrentDirectoryA(char *lpBuffer)
HANDLE hHandle;
WIN32_FIND_DATA win32FD;
char szBuffer[MAX_PATH+1], *pPtr;
- int nRet = -1;
+ int length, nRet = -1;
GetFullPathNameA(MapPathA(lpBuffer), sizeof(szBuffer), szBuffer, &pPtr);
+ /* if the last char is a '\\' or a '/' then add
+ * an '*' before calling FindFirstFile
+ */
+ length = strlen(szBuffer);
+ if(length > 0 && IsPathSep(szBuffer[length-1])) {
+ szBuffer[length] = '*';
+ szBuffer[length+1] = '\0';
+ }
- hHandle = FindFirstFile(szBuffer, &win32FD);
+ hHandle = FindFirstFileA(szBuffer, &win32FD);
if (hHandle != INVALID_HANDLE_VALUE) {
FindClose(hHandle);
- SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0]));
- nRet = 0;
- }
- return nRet;
-}
-
-int VDir::SetCurrentDirectoryW(WCHAR *lpBuffer)
-{
- HANDLE hHandle;
- WIN32_FIND_DATAW win32FD;
- WCHAR szBuffer[MAX_PATH+1], *pPtr;
- int nRet = -1;
- GetFullPathNameW(MapPathW(lpBuffer), (sizeof(szBuffer)/sizeof(WCHAR)), szBuffer, &pPtr);
+ /* if an '*' was added remove it */
+ if(szBuffer[length] == '*')
+ szBuffer[length] = '\0';
- hHandle = FindFirstFileW(szBuffer, &win32FD);
- if (hHandle != INVALID_HANDLE_VALUE) {
- FindClose(hHandle);
- SetDefaultDirW(szBuffer, DriveIndex((char)szBuffer[0]));
+ SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0]));
nRet = 0;
}
return nRet;
@@ -463,5 +458,35 @@ WCHAR* VDir::MapPathW(const WCHAR *pInName)
return szLocalBufferW;
}
+int VDir::SetCurrentDirectoryW(WCHAR *lpBuffer)
+{
+ HANDLE hHandle;
+ WIN32_FIND_DATAW win32FD;
+ WCHAR szBuffer[MAX_PATH+1], *pPtr;
+ int length, nRet = -1;
+
+ GetFullPathNameW(MapPathW(lpBuffer), (sizeof(szBuffer)/sizeof(WCHAR)), szBuffer, &pPtr);
+ /* if the last char is a '\\' or a '/' then add
+ * an '*' before calling FindFirstFile
+ */
+ length = wcslen(szBuffer);
+ if(length > 0 && IsPathSep(szBuffer[length-1])) {
+ szBuffer[length] = '*';
+ szBuffer[length+1] = '\0';
+ }
+
+ hHandle = FindFirstFileW(szBuffer, &win32FD);
+ if (hHandle != INVALID_HANDLE_VALUE) {
+ FindClose(hHandle);
+
+ /* if an '*' was added remove it */
+ if(szBuffer[length] == '*')
+ szBuffer[length] = '\0';
+
+ SetDefaultDirW(szBuffer, DriveIndex((char)szBuffer[0]));
+ nRet = 0;
+ }
+ return nRet;
+}
#endif /* ___VDir_H___ */