This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Added win32/.gitignore to ignore stuff from the Windows build
[perl5.git] / win32 / vdir.h
index fb80e38..db7ec84 100644 (file)
@@ -153,7 +153,7 @@ void VDir::Init(VDir* pDir, VMem *p)
         GetVersionEx(&osver);
 
        bManageDirectory = 0;
-        if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+        if (osver.dwMajorVersion < 5) {
             char szBuffer[MAX_PATH*driveCount];
             if (GetLogicalDriveStringsA(sizeof(szBuffer), szBuffer)) {
                 char* pEnv = (char*)GetEnvironmentStringsA();
@@ -168,7 +168,7 @@ void VDir::Init(VDir* pDir, VMem *p)
             }
             SetDefaultA(".");
         }
-        else { /* Windows NT or later */
+        else { /* Windows 2000 or later */
             WCHAR szBuffer[MAX_PATH*driveCount];
             if (GetLogicalDriveStringsW(sizeof(szBuffer), szBuffer)) {
                 WCHAR* pEnv = GetEnvironmentStringsW();
@@ -261,13 +261,13 @@ void VDir::SetDefaultA(char const *pDefault)
 int VDir::SetDirW(WCHAR const *pPath, int index)
 {
     WCHAR chr, *ptr;
-    char szBuffer[MAX_PATH+1];
     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) {
+            char *ansi;
            wcscpy(ptr, pPath);
            ptr += length-1;
            chr = *ptr++;
@@ -275,13 +275,14 @@ int VDir::SetDirW(WCHAR const *pPath, int index)
                *ptr++ = '\\';
                *ptr = '\0';
            }
-           WideCharToMultiByte(CP_ACP, 0, dirTableW[index], -1, szBuffer, sizeof(szBuffer), NULL, NULL);
-           length = strlen(szBuffer);
+            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], szBuffer);
+               strcpy(dirTableA[index], ansi);
            }
+            win32_free(ansi);
        }
     }
 
@@ -315,7 +316,7 @@ inline void DoGetFullPathNameA(char* lpBuffer, DWORD dwSize, char* Dest)
 
     /*
      * On WinNT GetFullPathName does not fail, (or at least always
-     * succeeds when the drive is valid) WinNT does set *Dest to Nullch
+     * succeeds when the drive is valid) WinNT does set *Dest to NULL
      * On Win98 GetFullPathName will set last error if it fails, but
      * does not touch *Dest
      */
@@ -543,7 +544,7 @@ inline void DoGetFullPathNameW(WCHAR* lpBuffer, DWORD dwSize, WCHAR* Dest)
 
     /*
      * On WinNT GetFullPathName does not fail, (or at least always
-     * succeeds when the drive is valid) WinNT does set *Dest to Nullch
+     * succeeds when the drive is valid) WinNT does set *Dest to NULL
      * On Win98 GetFullPathName will set last error if it fails, but
      * does not touch *Dest
      */