added wxFileName::GetVolumeString() (#9950)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-09-14 01:18:05 +00:00
parent 19abad600c
commit 35c2aa4f19
4 changed files with 74 additions and 19 deletions

View File

@@ -40,6 +40,7 @@
#include "wx/module.h"
#endif
#include "wx/filename.h"
#include "wx/filefn.h"
#include "wx/imaglist.h"
#include "wx/tokenzr.h"
@@ -108,7 +109,7 @@ bool wxIsDriveAvailable(const wxString& dirName);
size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids)
{
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
#ifdef wxHAS_FILESYSTEM_VOLUMES
#ifdef __WXWINCE__
// No logical drives; return "\"
@@ -164,9 +165,10 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
{
if (ulDriveMap & ( 1 << i ))
{
wxString path, name;
path.Printf(wxT("%c:\\"), 'A' + i);
name.Printf(wxT("%c:"), 'A' + i);
const wxString path = wxFileName::GetVolumeString(
'A' + i, wxPATH_GET_SEPARATOR);
const wxString name = wxFileName::GetVolumeString(
'A' + i, wxPATH_NO_SEPARATOR);
// Note: If _filesys is unsupported by some compilers,
// we can always replace it by DosQueryFSAttach
@@ -201,20 +203,18 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
}
}
#else // !__WIN32__, !__OS2__
int drive;
/* If we can switch to the drive, it exists. */
for( drive = 1; drive <= 26; drive++ )
for ( char drive = 'A'; drive <= 'Z'; drive++ )
{
wxString path, name;
path.Printf(wxT("%c:\\"), (char) (drive + 'a' - 1));
name.Printf(wxT("%c:"), (char) (drive + 'A' - 1));
const wxString
path = wxFileName::GetVolumeString(drive, wxPATH_GET_SEPARATOR);
if (wxIsDriveAvailable(path))
{
paths.Add(path);
names.Add(name);
icon_ids.Add((drive <= 2) ? wxFileIconsTable::floppy : wxFileIconsTable::drive);
names.Add(wxFileName::GetVolumeString(drive, wxPATH_NO_SEPARATOR));
icon_ids.Add(drive <= 2 ? wxFileIconsTable::floppy
: wxFileIconsTable::drive);
}
}
#endif // __WIN32__/!__WIN32__