From 006b7af2b256afa8608630e796b6cf6a04b2bba5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 2 Feb 2007 23:59:00 +0000 Subject: [PATCH] use wxFSVolume instead of duplicating its functionality in the (MSW branch of) wxGetAvailableDrives() (patch 1615074) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44349 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/dirctrlg.cpp | 49 ++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 5b9bc12d62..4aaa290e8b 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -58,6 +58,7 @@ #ifdef __WXMSW__ #include #include "wx/msw/winundef.h" +#include "wx/volume.h" // FIXME - Mingw32 1.0 has both _getdrive() and _chdrive(). For now, let's assume // older releases don't, but it should be verified and the checks modified @@ -111,48 +112,42 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI paths.Add(wxT("\\")); names.Add(wxT("\\")); icon_ids.Add(wxFileIconsTable::computer); -#elif defined(__WIN32__) - wxChar driveBuffer[256]; - size_t n = (size_t) GetLogicalDriveStrings(255, driveBuffer); - size_t i = 0; - while (i < n) - { - wxString path, name; - path.Printf(wxT("%c:\\"), driveBuffer[i]); - name.Printf(wxT("%c:"), driveBuffer[i]); - - // Do not use GetVolumeInformation to further decorate the - // name, since it can cause severe delays on network drives. +#elif defined(__WIN32__) && wxUSE_FSVOLUME + // TODO: this code (using wxFSVolumeBase) should be used for all platforms + // but unfortunately wxFSVolumeBase is not implemented everywhere + const wxArrayString as = wxFSVolumeBase::GetVolumes(); + for (size_t i = 0; i < as.GetCount(); i++) + { + wxString path = as[i]; + wxFSVolume vol(path); int imageId; - int driveType = ::GetDriveType(path); - switch (driveType) + switch (vol.GetKind()) { - case DRIVE_REMOVABLE: - if (path == wxT("a:\\") || path == wxT("b:\\")) + case wxFS_VOL_FLOPPY: + if ( (path == wxT("a:\\")) || (path == wxT("b:\\")) ) imageId = wxFileIconsTable::floppy; else imageId = wxFileIconsTable::removeable; break; - case DRIVE_CDROM: + case wxFS_VOL_DVDROM: + case wxFS_VOL_CDROM: imageId = wxFileIconsTable::cdrom; break; - case DRIVE_REMOTE: - case DRIVE_FIXED: + case wxFS_VOL_NETWORK: + if (path[0] == wxT('\\')) + continue; // skip "\\computer\folder" + imageId = wxFileIconsTable::drive; + break; + case wxFS_VOL_DISK: + case wxFS_VOL_OTHER: default: imageId = wxFileIconsTable::drive; break; } - paths.Add(path); - names.Add(name); + names.Add(vol.GetDisplayName()); icon_ids.Add(imageId); - - while (driveBuffer[i] != wxT('\0')) - i ++; - i ++; - if (driveBuffer[i] == wxT('\0')) - break; } #elif defined(__OS2__) APIRET rc; -- 2.45.2