X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f5c6eb5c178b44f4400495e06274ffd130635190..80c82e01758cd838aa5c922b848454277b11da26:/src/mac/dirmac.cpp diff --git a/src/mac/dirmac.cpp b/src/mac/dirmac.cpp index 36835cd68c..0ccaf0b8e9 100644 --- a/src/mac/dirmac.cpp +++ b/src/mac/dirmac.cpp @@ -40,12 +40,10 @@ #include #endif -#ifndef __DARWIN__ - #include "morefile.h" - #include "moreextr.h" - #include "fullpath.h" - #include "fspcompa.h" -#endif +#include "wx/mac/private.h" + +#include "MoreFiles.h" +#include "MoreFilesExtras.h" // ---------------------------------------------------------------------------- // constants @@ -78,6 +76,8 @@ public: bool Read(wxString *filename); // reads the next void Rewind() ; + const wxString& GetName() const { return m_dirname; } + private: CInfoPBRec m_CPB ; wxInt16 m_index ; @@ -118,11 +118,8 @@ wxDirData::wxDirData(const wxString& dirname) m_CPB.hFileInfo.ioNamePtr = m_name ; m_index = 0 ; -#ifdef __DARWIN__ - // TODO: what are we supposed to do for Mac OS X -#else - FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ; -#endif + OSErr err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ; + wxASSERT_MSG( err == noErr , "Error accessing directory") ; } wxDirData::~wxDirData() @@ -160,6 +157,11 @@ bool wxDirData::Read(wxString *filename) strcpy( (char *)m_name, c_name); #else p2cstr( m_name ) ; +#endif +#if TARGET_CARBON + // under X thats the way the mounting points look like + if ( ( m_CPB.dirInfo.ioDrDirID == 0 ) && ( m_flags & wxDIR_DIRS) ) + break ; #endif if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory break ; @@ -171,7 +173,7 @@ bool wxDirData::Read(wxString *filename) continue ; wxString file( m_name ) ; - if ( m_filespec.IsEmpty() || m_filespec == "*.*" ) + if ( m_filespec.IsEmpty() || m_filespec == "*.*" || m_filespec == "*" ) { } else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" ) @@ -239,9 +241,28 @@ bool wxDir::IsOpened() const return m_data != NULL; } +wxString wxDir::GetName() const +{ + wxString name; + if ( m_data ) + { + name = M_DIR->GetName(); + if ( !name.empty() && (name.Last() == _T('/')) ) + { + // chop off the last (back)slash + name.Truncate(name.length() - 1); + } + } + + return name; +} + wxDir::~wxDir() { - delete M_DIR; + if (M_DIR != NULL) { + delete M_DIR; + m_data = NULL; + } } // ----------------------------------------------------------------------------