X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3438012b66bee7c98b521c493f3e37ff275103af..8fd0d89b7dc8ed4ed7e460ddc9b61ae4a0e63c3e:/src/generic/dirctrlg.cpp diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index d20e028b0d..4ff52eddb7 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -48,11 +48,15 @@ #ifdef __WXMSW__ #include + +#ifndef __GNUWIN32__ #include #include #include #endif +#endif + #ifdef __BORLANDC__ #include "dos.h" #endif @@ -293,7 +297,7 @@ static const int ID_CANCEL = 1003; static const int ID_NEW = 1004; //static const int ID_CHECK = 1005; -#ifdef __WXMSW__ +#if defined(__WXMSW__) static bool wxIsDriveAvailable(const wxString dirName) { #ifdef __WIN32__ @@ -306,6 +310,9 @@ static bool wxIsDriveAvailable(const wxString dirName) if (dirName.Len() == 3 && dirName[(size_t)1] == wxT(':')) { wxString dirNameLower(dirName.Lower()); +#if defined(__GNUWIN32__) + success = wxPathExists(dirNameLower); +#else int currentDrive = _getdrive(); int thisDrive = (int) (dirNameLower[(size_t)0] - 'a' + 1) ; int err = _chdrive( thisDrive ) ; @@ -315,6 +322,7 @@ static bool wxIsDriveAvailable(const wxString dirName) { success = FALSE; } +#endif } #ifdef __WIN32__ (void) SetErrorMode(errorMode); @@ -354,32 +362,6 @@ void wxDirItemDataEx::SetNewDirName( wxString path ) m_name = wxFileNameFromPath( path ); } -// No longer used, and takes a very long time -bool wxDirItemDataEx::HasSubDirs() -{ - if (m_path.IsEmpty()) - return TRUE; - - // On WIN32, must check if this volume is mounted or - // we get an error dialog for e.g. drive a: -#ifdef __WIN32__ - if (!wxIsDriveAvailable(m_path)) - return FALSE; -#endif - - wxString search = m_path; - - if (m_path.Last() != wxFILE_SEP_PATH) - { - search += wxString(wxFILE_SEP_PATH); - } - search += wxT("*"); - - wxLogNull log; - wxString path = wxFindFirstFile( search, wxDIR ); - return (bool)(!path.IsNull()); -} - //----------------------------------------------------------------------------- // wxGenericDirCtrl //----------------------------------------------------------------------------- @@ -710,8 +692,8 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) if (!wxIsDriveAvailable(dirName)) { data->m_isExpanded = FALSE; - wxMessageBox(wxT("Sorry, this drive is not available.")); - return; + //wxMessageBox(wxT("Sorry, this drive is not available.")); + return; } #endif @@ -845,7 +827,7 @@ wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString& long cookie; wxTreeItemId childId = m_treeCtrl->GetFirstChild(parentId, cookie); - while (childId != 0) + while (childId.IsOk()) { wxDirItemDataEx* data = (wxDirItemDataEx*) m_treeCtrl->GetItemData(childId); @@ -887,15 +869,15 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path) bool done = FALSE; wxTreeItemId id = FindChild(m_rootId, path, done); wxTreeItemId lastId = id; // The last non-zero id - while ((id > 0) && !done) + while (id.IsOk() && !done) { ExpandDir(id); id = FindChild(id, path, done); - if (id != 0) + if (id.IsOk()) lastId = id; } - if (lastId > 0) + if (lastId.IsOk()) { wxDirItemDataEx *data = (wxDirItemDataEx *) m_treeCtrl->GetItemData(lastId); if (data->m_isDir) @@ -908,7 +890,7 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path) long cookie; wxTreeItemId childId = m_treeCtrl->GetFirstChild(lastId, cookie); bool selectedChild = FALSE; - while (childId != 0) + while (childId.IsOk()) { wxDirItemDataEx* data = (wxDirItemDataEx*) m_treeCtrl->GetItemData(childId);