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
This commit is contained in:
@@ -58,6 +58,7 @@
|
|||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "wx/msw/winundef.h"
|
#include "wx/msw/winundef.h"
|
||||||
|
#include "wx/volume.h"
|
||||||
|
|
||||||
// FIXME - Mingw32 1.0 has both _getdrive() and _chdrive(). For now, let's assume
|
// 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
|
// 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("\\"));
|
paths.Add(wxT("\\"));
|
||||||
names.Add(wxT("\\"));
|
names.Add(wxT("\\"));
|
||||||
icon_ids.Add(wxFileIconsTable::computer);
|
icon_ids.Add(wxFileIconsTable::computer);
|
||||||
#elif defined(__WIN32__)
|
#elif defined(__WIN32__) && wxUSE_FSVOLUME
|
||||||
wxChar driveBuffer[256];
|
// TODO: this code (using wxFSVolumeBase) should be used for all platforms
|
||||||
size_t n = (size_t) GetLogicalDriveStrings(255, driveBuffer);
|
// but unfortunately wxFSVolumeBase is not implemented everywhere
|
||||||
size_t i = 0;
|
const wxArrayString as = wxFSVolumeBase::GetVolumes();
|
||||||
while (i < n)
|
|
||||||
|
for (size_t i = 0; i < as.GetCount(); i++)
|
||||||
{
|
{
|
||||||
wxString path, name;
|
wxString path = as[i];
|
||||||
path.Printf(wxT("%c:\\"), driveBuffer[i]);
|
wxFSVolume vol(path);
|
||||||
name.Printf(wxT("%c:"), driveBuffer[i]);
|
|
||||||
|
|
||||||
// Do not use GetVolumeInformation to further decorate the
|
|
||||||
// name, since it can cause severe delays on network drives.
|
|
||||||
|
|
||||||
int imageId;
|
int imageId;
|
||||||
int driveType = ::GetDriveType(path);
|
switch (vol.GetKind())
|
||||||
switch (driveType)
|
|
||||||
{
|
{
|
||||||
case DRIVE_REMOVABLE:
|
case wxFS_VOL_FLOPPY:
|
||||||
if (path == wxT("a:\\") || path == wxT("b:\\"))
|
if ( (path == wxT("a:\\")) || (path == wxT("b:\\")) )
|
||||||
imageId = wxFileIconsTable::floppy;
|
imageId = wxFileIconsTable::floppy;
|
||||||
else
|
else
|
||||||
imageId = wxFileIconsTable::removeable;
|
imageId = wxFileIconsTable::removeable;
|
||||||
break;
|
break;
|
||||||
case DRIVE_CDROM:
|
case wxFS_VOL_DVDROM:
|
||||||
|
case wxFS_VOL_CDROM:
|
||||||
imageId = wxFileIconsTable::cdrom;
|
imageId = wxFileIconsTable::cdrom;
|
||||||
break;
|
break;
|
||||||
case DRIVE_REMOTE:
|
case wxFS_VOL_NETWORK:
|
||||||
case DRIVE_FIXED:
|
if (path[0] == wxT('\\'))
|
||||||
|
continue; // skip "\\computer\folder"
|
||||||
|
imageId = wxFileIconsTable::drive;
|
||||||
|
break;
|
||||||
|
case wxFS_VOL_DISK:
|
||||||
|
case wxFS_VOL_OTHER:
|
||||||
default:
|
default:
|
||||||
imageId = wxFileIconsTable::drive;
|
imageId = wxFileIconsTable::drive;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
paths.Add(path);
|
paths.Add(path);
|
||||||
names.Add(name);
|
names.Add(vol.GetDisplayName());
|
||||||
icon_ids.Add(imageId);
|
icon_ids.Add(imageId);
|
||||||
|
|
||||||
while (driveBuffer[i] != wxT('\0'))
|
|
||||||
i ++;
|
|
||||||
i ++;
|
|
||||||
if (driveBuffer[i] == wxT('\0'))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
APIRET rc;
|
APIRET rc;
|
||||||
|
Reference in New Issue
Block a user