- wxStrcpy(wxBuffer, zHome);
- wxUnix2DosFilename(wxBuffer);
-#if wxUSE_UNICODE
- wxWCharBuffer retBuffer (wxBuffer);
- delete[] wxBuffer;
- return retBuffer;
-#else
- wxStrcpy(zHome, wxBuffer);
- delete[] wxBuffer;
- return zHome;
-#endif
+ home = zHome;
+ home.Replace("/", "\\");
+ }
+ }
+
+ return home;
+}
+
+bool wxGetDiskSpace(const wxString& path,
+ wxDiskspaceSize_t *pTotal,
+ wxDiskspaceSize_t *pFree)
+{
+ if (path.empty())
+ return false;
+
+ wxFileName fn(path);
+ FSALLOCATE fsaBuf = {0};
+ APIRET rc = NO_ERROR;
+ ULONG disknum = 0;
+
+ fn.MakeAbsolute();
+
+ if (wxDirExists(fn.GetFullPath()) == false)
+ return false;
+
+ disknum = wxToupper(fn.GetVolume().GetChar(0)) - wxT('A') + 1;
+
+ rc = ::DosQueryFSInfo(disknum, // 1 = A, 2 = B, 3 = C, ...
+ FSIL_ALLOC, // allocation info
+ (PVOID)&fsaBuf,
+ sizeof(FSALLOCATE));
+
+ if (rc != NO_ERROR)
+ return false;
+ else
+ {
+ if(pTotal)
+ {
+ // to try to avoid 32-bit overflow, let's not multiply right away
+ // (num of alloc units)
+ *pTotal = fsaBuf.cUnit;
+ // * (num of sectors per alloc unit) * (num of bytes per sector)
+ (*pTotal) *= fsaBuf.cSectorUnit * fsaBuf.cbSector;
+ }
+ if(pFree)
+ {
+ *pFree = fsaBuf.cUnitAvail;
+ (*pFree) *= fsaBuf.cSectorUnit * fsaBuf.cbSector;