X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3dee36ae33edfa99460ce71e928678e1282df844..6cef0db28018fd2644ee4e38af715872e5242459:/src/mac/carbon/dirmac.cpp?ds=sidebyside diff --git a/src/mac/carbon/dirmac.cpp b/src/mac/carbon/dirmac.cpp index 85dd3e2535..52e9a61e0f 100644 --- a/src/mac/carbon/dirmac.cpp +++ b/src/mac/carbon/dirmac.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: msw/dir.cpp +// Name: mac/dirmac.cpp // Purpose: wxDir implementation for Mac // Author: Stefan Csomor // Modified by: @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "dir.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -28,37 +24,17 @@ #pragma hdrstop #endif +#include "wx/dir.h" + #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/log.h" #endif // PCH -#include "wx/dir.h" #include "wx/filefn.h" // for wxDirExists() - -#ifndef __DARWIN__ - #include -#endif - #include "wx/filename.h" #include "wx/mac/private.h" -#include "MoreFilesX.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -#ifndef MAX_PATH - #define MAX_PATH 260 // from VC++ headers -#endif - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -#define M_DIR ((wxDirData *)m_data) - // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- @@ -149,24 +125,29 @@ bool wxDirData::Read(wxString *filename) } wxString name ; + wxString lowerfilespec = m_filespec.Lower(); while( noErr == err ) { HFSUniStr255 uniname ; FSRef fileRef; FSCatalogInfo catalogInfo; - UInt32 fetched = 0; + ItemCount fetched = 0; err = FSGetCatalogInfoBulk( m_iterator, 1, &fetched, NULL, kFSCatInfoNodeFlags | kFSCatInfoFinderInfo , &catalogInfo , &fileRef, NULL, &uniname ); + + // expected error codes + if ( errFSNoMoreItems == err ) return false ; - - wxASSERT( noErr == err ) ; + if ( afpAccessDenied == err ) + return false ; if ( noErr != err ) break ; name = wxMacHFSUniStrToString( &uniname ) ; + wxString lowername = name.Lower(); if ( ( name == wxT(".") || name == wxT("..") ) && !(m_flags & wxDIR_DOTDOT) ) continue; @@ -188,7 +169,7 @@ bool wxDirData::Read(wxString *filename) if ( m_filespec.empty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") ) { } - else if ( !wxMatchWild(m_filespec, name , false) ) + else if ( !wxMatchWild(lowerfilespec, lowername , false) ) { continue ; } @@ -227,7 +208,7 @@ wxDir::wxDir(const wxString& dirname) bool wxDir::Open(const wxString& dirname) { - delete M_DIR; + delete m_data; m_data = new wxDirData(dirname); return true; @@ -243,7 +224,7 @@ wxString wxDir::GetName() const wxString name; if ( m_data ) { - name = M_DIR->GetName(); + name = m_data->GetName(); if ( !name.empty() && (name.Last() == _T('/')) ) { // chop off the last (back)slash @@ -256,10 +237,8 @@ wxString wxDir::GetName() const wxDir::~wxDir() { - if (M_DIR != NULL) { - delete M_DIR; - m_data = NULL; - } + delete m_data; + m_data = NULL; } // ---------------------------------------------------------------------------- @@ -272,10 +251,10 @@ bool wxDir::GetFirst(wxString *filename, { wxCHECK_MSG( IsOpened(), false, _T("must wxDir::Open() first") ); - M_DIR->Rewind(); + m_data->Rewind(); - M_DIR->SetFileSpec(filespec); - M_DIR->SetFlags(flags); + m_data->SetFileSpec(filespec); + m_data->SetFlags(flags); return GetNext(filename); } @@ -286,5 +265,5 @@ bool wxDir::GetNext(wxString *filename) const wxCHECK_MSG( filename, false, _T("bad pointer in wxDir::GetNext()") ); - return M_DIR->Read(filename); + return m_data->Read(filename); }