Fixed drive handling on OS/2.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@24648 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,6 +20,10 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __EMX__
|
||||||
|
#define __OS2__
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_DIRDLG
|
#if wxUSE_DIRDLG
|
||||||
|
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
@@ -66,7 +70,7 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXPM__
|
#ifdef __OS2__
|
||||||
|
|
||||||
#define INCL_BASE
|
#define INCL_BASE
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
@@ -76,7 +80,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#endif // __WXPM__
|
#endif // __OS2__
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
# include "MoreFilesExtras.h"
|
# include "MoreFilesExtras.h"
|
||||||
@@ -334,7 +338,7 @@ bool wxIsDriveAvailable(const wxString& dirName)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__WINDOWS__) || defined(__WXPM__)
|
#elif defined(__WINDOWS__) || defined(__OS2__)
|
||||||
|
|
||||||
int setdrive(int drive)
|
int setdrive(int drive)
|
||||||
{
|
{
|
||||||
@@ -342,13 +346,18 @@ int setdrive(int drive)
|
|||||||
(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
|
(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
|
||||||
return _chdrive(drive);
|
return _chdrive(drive);
|
||||||
#else
|
#else
|
||||||
wxChar newdrive[3];
|
wxChar newdrive[4];
|
||||||
|
|
||||||
if (drive < 1 || drive > 31)
|
if (drive < 1 || drive > 31)
|
||||||
return -1;
|
return -1;
|
||||||
newdrive[0] = (wxChar)(wxT('A') + drive - 1);
|
newdrive[0] = (wxChar)(wxT('A') + drive - 1);
|
||||||
newdrive[1] = wxT(':');
|
newdrive[1] = wxT(':');
|
||||||
|
#ifdef __OS2__
|
||||||
|
newdrive[2] = wxT('\\');
|
||||||
|
newdrive[3] = wxT('\0');
|
||||||
|
#else
|
||||||
newdrive[2] = wxT('\0');
|
newdrive[2] = wxT('\0');
|
||||||
|
#endif
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
#ifdef __WIN16__
|
#ifdef __WIN16__
|
||||||
if (wxSetWorkingDirectory(newdrive))
|
if (wxSetWorkingDirectory(newdrive))
|
||||||
@@ -357,7 +366,7 @@ int setdrive(int drive)
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
// VA doesn't know what LPSTR is and has its own set
|
// VA doesn't know what LPSTR is and has its own set
|
||||||
if (DosSetCurrentDir((PSZ)newdrive))
|
if (!DosSetCurrentDir((PSZ)newdrive))
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
@@ -381,6 +390,11 @@ bool wxIsDriveAvailable(const wxString& dirName)
|
|||||||
!(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1))
|
!(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1))
|
||||||
success = wxPathExists(dirNameLower);
|
success = wxPathExists(dirNameLower);
|
||||||
#else
|
#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 currentDrive = _getdrive();
|
||||||
int thisDrive = (int) (dirNameLower[(size_t)0] - 'a' + 1) ;
|
int thisDrive = (int) (dirNameLower[(size_t)0] - 'a' + 1) ;
|
||||||
int err = setdrive( thisDrive ) ;
|
int err = setdrive( thisDrive ) ;
|
||||||
@@ -398,7 +412,8 @@ bool wxIsDriveAvailable(const wxString& dirName)
|
|||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
#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,
|
||||||
// and sort regardless of case.
|
// and sort regardless of case.
|
||||||
@@ -549,7 +564,7 @@ bool wxGenericDirCtrl::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxString rootName;
|
wxString rootName;
|
||||||
|
|
||||||
#if defined(__WINDOWS__) || defined(__WXPM__) || defined(__DOS__)
|
#if defined(__WINDOWS__) || defined(__OS2__) || defined(__DOS__)
|
||||||
rootName = _("Computer");
|
rootName = _("Computer");
|
||||||
#else
|
#else
|
||||||
rootName = _("Sections");
|
rootName = _("Sections");
|
||||||
@@ -602,7 +617,7 @@ void wxGenericDirCtrl::AddSection(const wxString& path, const wxString& name, in
|
|||||||
|
|
||||||
void wxGenericDirCtrl::SetupSections()
|
void wxGenericDirCtrl::SetupSections()
|
||||||
{
|
{
|
||||||
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
|
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
wxChar driveBuffer[256];
|
wxChar driveBuffer[256];
|
||||||
@@ -800,7 +815,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId)
|
|||||||
|
|
||||||
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,
|
// Check if this is a root directory and if so,
|
||||||
// whether the drive is avaiable.
|
// whether the drive is avaiable.
|
||||||
if (!wxIsDriveAvailable(dirName))
|
if (!wxIsDriveAvailable(dirName))
|
||||||
@@ -814,7 +829,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId)
|
|||||||
// This may take a longish time. Go to busy cursor
|
// This may take a longish time. Go to busy cursor
|
||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
|
|
||||||
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
|
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
|
||||||
if (dirName.Last() == ':')
|
if (dirName.Last() == ':')
|
||||||
dirName += wxString(wxFILE_SEP_PATH);
|
dirName += wxString(wxFILE_SEP_PATH);
|
||||||
#endif
|
#endif
|
||||||
@@ -934,7 +949,7 @@ wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString&
|
|||||||
path2 += wxString(wxFILE_SEP_PATH);
|
path2 += wxString(wxFILE_SEP_PATH);
|
||||||
|
|
||||||
// In MSW or PM, case is not significant
|
// In MSW or PM, case is not significant
|
||||||
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
|
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
|
||||||
path2.MakeLower();
|
path2.MakeLower();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -951,7 +966,7 @@ wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString&
|
|||||||
childPath += wxString(wxFILE_SEP_PATH);
|
childPath += wxString(wxFILE_SEP_PATH);
|
||||||
|
|
||||||
// In MSW and PM, case is not significant
|
// In MSW and PM, case is not significant
|
||||||
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__)
|
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
|
||||||
childPath.MakeLower();
|
childPath.MakeLower();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1083,7 +1098,7 @@ void wxGenericDirCtrl::FindChildFiles(wxTreeItemId id, int dirFlags, wxArrayStri
|
|||||||
|
|
||||||
wxString dirName(data->m_path);
|
wxString dirName(data->m_path);
|
||||||
|
|
||||||
#if defined(__WXMSW__) || defined(__WXPM__)
|
#if defined(__WXMSW__) || defined(__OS2__)
|
||||||
if (dirName.Last() == ':')
|
if (dirName.Last() == ':')
|
||||||
dirName += wxString(wxFILE_SEP_PATH);
|
dirName += wxString(wxFILE_SEP_PATH);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user