git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24648
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#define INCL_BASE
#include <os2.h>
#define INCL_BASE
#include <os2.h>
#include <stdlib.h>
#include <ctype.h>
extern bool wxIsDriveAvailable(const wxString& dirName);
#include <stdlib.h>
#include <ctype.h>
extern bool wxIsDriveAvailable(const wxString& dirName);
#if defined(__WXMAC__)
# ifdef __DARWIN__
#if defined(__WXMAC__)
# ifdef __DARWIN__
#endif
// ----------------------------------------------------------------------------
#endif
// ----------------------------------------------------------------------------
-// wxGetAvailableDrives, for WINDOWS, DOS, WXPM, MAC, UNIX (returns "/")
+// wxGetAvailableDrives, for WINDOWS, DOS, OS2, MAC, UNIX (returns "/")
// ----------------------------------------------------------------------------
size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids)
{
// ----------------------------------------------------------------------------
size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids)
{
-#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
+#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
#ifdef __WXWINCE__
// No logical drives; return "\"
#ifdef __WXWINCE__
// No logical drives; return "\"
if (driveBuffer[i] == wxT('\0'))
break;
}
if (driveBuffer[i] == wxT('\0'))
break;
}
+#elif defined(__OS2__)
+ APIRET rc;
+ ULONG ulDriveNum = 0;
+ ULONG ulDriveMap = 0;
+ rc = ::DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);
+ if ( rc == 0){
+ size_t i = 0;
+ while (i < 26)
+ {
+ if (ulDriveMap & ( 1 << i ))
+ {
+ wxString path, name;
+ path.Printf(wxT("%c:\\"), 'A' + i);
+ name.Printf(wxT("%c:"), 'A' + i);
+
+ int imageId;
+ if (path == wxT("A:\\") || path == wxT("B:\\"))
+ imageId = wxFileIconsTable::floppy;
+ else
+ imageId = wxFileIconsTable::drive;
+ paths.Add(path);
+ names.Add(name);
+ icon_ids.Add(imageId);
+ }
+ i ++;
+ }
+ }
+#else // !__WIN32__, !__OS2__
int drive;
/* If we can switch to the drive, it exists. */
int drive;
/* If we can switch to the drive, it exists. */
-#elif defined(__WINDOWS__) || defined(__WXPM__)
+#elif defined(__WINDOWS__) || defined(__OS2__)
int setdrive(int drive)
{
int setdrive(int drive)
{
(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
return _chdrive(drive);
#else
(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
return _chdrive(drive);
#else
if (drive < 1 || drive > 31)
return -1;
newdrive[0] = (wxChar)(wxT('A') + drive - 1);
newdrive[1] = wxT(':');
if (drive < 1 || drive > 31)
return -1;
newdrive[0] = (wxChar)(wxT('A') + drive - 1);
newdrive[1] = wxT(':');
+#ifdef __OS2__
+ newdrive[2] = wxT('\\');
+ newdrive[3] = wxT('\0');
+#else
#if defined(__WXMSW__)
if (::SetCurrentDirectory(newdrive))
#else
// VA doesn't know what LPSTR is and has its own set
#if defined(__WXMSW__)
if (::SetCurrentDirectory(newdrive))
#else
// VA doesn't know what LPSTR is and has its own set
- if (DosSetCurrentDir((PSZ)newdrive))
+ if (!DosSetCurrentDir((PSZ)newdrive))
#if defined(__GNUWIN32__) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
success = wxPathExists(dirNameLower);
#else
#if defined(__GNUWIN32__) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
success = wxPathExists(dirNameLower);
#else
+ #if defined(__OS2__)
+ // Avoid changing to drive since no media may be inserted.
+ if (dirNameLower[(size_t)0] == 'a' || dirNameLower[(size_t)0] == 'b')
+ return success;
+ #endif
int currentDrive = _getdrive();
int thisDrive = (int) (dirNameLower[(size_t)0] - 'a' + 1) ;
int err = setdrive( thisDrive ) ;
int currentDrive = _getdrive();
int thisDrive = (int) (dirNameLower[(size_t)0] - 'a' + 1) ;
int err = setdrive( thisDrive ) ;
-#endif // __WINDOWS__ || __WXPM__
+#endif // __WINDOWS__ || __OS2__
// Function which is called by quick sort. We want to override the default wxArrayString behaviour,
// Function which is called by quick sort. We want to override the default wxArrayString behaviour,
-#if defined(__WINDOWS__) || defined(__WXPM__) || defined(__DOS__)
+#if defined(__WINDOWS__) || defined(__OS2__) || defined(__DOS__)
rootName = _("Computer");
#else
rootName = _("Sections");
rootName = _("Computer");
#else
rootName = _("Sections");
wxString dirName(data->m_path);
wxString dirName(data->m_path);
-#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
+#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
// Check if this is a root directory and if so,
// whether the drive is avaiable.
if (!wxIsDriveAvailable(dirName))
// Check if this is a root directory and if so,
// whether the drive is avaiable.
if (!wxIsDriveAvailable(dirName))
// This may take a longish time. Go to busy cursor
wxBusyCursor busy;
// This may take a longish time. Go to busy cursor
wxBusyCursor busy;
-#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
+#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
if (dirName.Last() == ':')
dirName += wxString(wxFILE_SEP_PATH);
#endif
if (dirName.Last() == ':')
dirName += wxString(wxFILE_SEP_PATH);
#endif
path2 += wxString(wxFILE_SEP_PATH);
// In MSW or PM, case is not significant
path2 += wxString(wxFILE_SEP_PATH);
// In MSW or PM, case is not significant
-#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
+#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
path2.MakeLower();
#endif
path2.MakeLower();
#endif
childPath += wxString(wxFILE_SEP_PATH);
// In MSW and PM, case is not significant
childPath += wxString(wxFILE_SEP_PATH);
// In MSW and PM, case is not significant
-#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
+#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
childPath.MakeLower();
#endif
childPath.MakeLower();
#endif
wxString dirName(data->m_path);
wxString dirName(data->m_path);
-#if defined(__WXMSW__) || defined(__WXPM__)
+#if defined(__WXMSW__) || defined(__OS2__)
if (dirName.Last() == ':')
dirName += wxString(wxFILE_SEP_PATH);
#endif
if (dirName.Last() == ':')
dirName += wxString(wxFILE_SEP_PATH);
#endif