X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=win32%2Fvdir.h;h=db7ec8417fef425597e9c36e18dc88b288beeb09;hb=e5973ed5ed7077edf70f4112414ae22c6300aec8;hp=2dd7e34cc6f8c9c6c628e697952bac74ed86de97;hpb=2eb25c996f78f171b9e185efef03146c255a8fd3;p=p5sagit%2Fp5-mst-13.2.git diff --git a/win32/vdir.h b/win32/vdir.h index 2dd7e34..db7ec84 100644 --- a/win32/vdir.h +++ b/win32/vdir.h @@ -34,47 +34,48 @@ public: inline char* GetCurrentDirectoryA(int dwBufSize, char *lpBuffer) { char* ptr = dirTableA[nDefault]; - while (dwBufSize--) + while (--dwBufSize) { if ((*lpBuffer++ = *ptr++) == '\0') break; } - return lpBuffer; + *lpBuffer = '\0'; + return /* unused */ NULL; }; inline WCHAR* GetCurrentDirectoryW(int dwBufSize, WCHAR *lpBuffer) { WCHAR* ptr = dirTableW[nDefault]; - while (dwBufSize--) + while (--dwBufSize) { if ((*lpBuffer++ = *ptr++) == '\0') break; } - return lpBuffer; + *lpBuffer = '\0'; + return /* unused */ NULL; }; - DWORD CalculateEnvironmentSpace(void); LPSTR BuildEnvironmentSpace(LPSTR lpStr); protected: int SetDirA(char const *pPath, int index); + int SetDirW(WCHAR const *pPath, int index); void FromEnvA(char *pEnv, int index); + void FromEnvW(WCHAR *pEnv, int index); + inline const char *GetDefaultDirA(void) { return dirTableA[nDefault]; }; - inline void SetDefaultDirA(char const *pPath, int index) { SetDirA(pPath, index); nDefault = index; }; - int SetDirW(WCHAR const *pPath, int index); inline const WCHAR *GetDefaultDirW(void) { return dirTableW[nDefault]; }; - inline void SetDefaultDirW(WCHAR const *pPath, int index) { SetDirW(pPath, index); @@ -134,9 +135,6 @@ VDir::VDir(int bManageDir /* = 1 */) void VDir::Init(VDir* pDir, VMem *p) { int index; - DWORD driveBits; - int nSave; - char szBuffer[MAX_PATH*driveCount]; pMem = p; if (pDir) { @@ -146,23 +144,47 @@ void VDir::Init(VDir* pDir, VMem *p) nDefault = pDir->GetDefault(); } else { - nSave = bManageDirectory; + int bSave = bManageDirectory; + DWORD driveBits = GetLogicalDrives(); + OSVERSIONINFO osver; + + memset(&osver, 0, sizeof(osver)); + osver.dwOSVersionInfoSize = sizeof(osver); + GetVersionEx(&osver); + bManageDirectory = 0; - driveBits = GetLogicalDrives(); - if (GetLogicalDriveStrings(sizeof(szBuffer), szBuffer)) { - char* pEnv = GetEnvironmentStrings(); - char* ptr = szBuffer; - for (index = 0; index < driveCount; ++index) { - if (driveBits & (1<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); } } @@ -281,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 */ @@ -509,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 */