X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/75633395579c4154980ed7cf3042ba0f35936120..30a936ee4eb950b4b1905b6bd09c90d3ec39fa99:/src/mac/carbon/dirmac.cpp?ds=sidebyside diff --git a/src/mac/carbon/dirmac.cpp b/src/mac/carbon/dirmac.cpp index 0f250ccd5e..ff168bafdc 100644 --- a/src/mac/carbon/dirmac.cpp +++ b/src/mac/carbon/dirmac.cpp @@ -6,7 +6,7 @@ // Created: 08.12.99 // RCS-ID: $Id$ // Copyright: (c) 1999 Stefan Csomor -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -83,11 +83,11 @@ public: const wxString& GetName() const { return m_dirname; } private: - CInfoPBRec m_CPB ; - wxInt16 m_index ; - long m_dirId ; - Str255 m_name ; - Boolean m_isDir ; + CInfoPBRec m_CPB ; + wxInt16 m_index ; + long m_dirId ; + Str255 m_name ; + Boolean m_isDir ; wxString m_dirname; wxString m_filespec; @@ -133,7 +133,7 @@ wxDirData::wxDirData(const wxString& dirname) err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ; #endif - wxASSERT_MSG( (err == noErr) || (err == nsvErr) , "Error accessing directory " + m_dirname) ; + wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ; m_CPB.hFileInfo.ioNamePtr = m_name ; m_index = 0 ; @@ -145,42 +145,33 @@ wxDirData::~wxDirData() void wxDirData::Rewind() { - m_index = 0 ; + m_index = 0 ; } bool wxDirData::Read(wxString *filename) { if ( !m_isDir ) return FALSE ; - -#if TARGET_CARBON - char c_name[256] ; -#endif + wxString result; short err = noErr ; - + while ( err == noErr ) { m_index++ ; m_CPB.dirInfo.ioFDirIndex = m_index; - m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */ + m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */ err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB); if ( err != noErr ) break ; -#if TARGET_CARBON - p2cstrcpy( c_name, m_name ) ; - strcpy( (char *)m_name, c_name); -#else - p2cstr( m_name ) ; -#endif // its hidden but we don't want it if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) continue ; #ifdef __DARWIN__ // under X, names that start with '.' are hidden - if ( ( m_name[0] == '.' ) && !(m_flags & wxDIR_HIDDEN) ) + if ( ( m_name[1] == '.' ) && !(m_flags & wxDIR_HIDDEN) ) continue; #endif #if TARGET_CARBON @@ -196,18 +187,18 @@ bool wxDirData::Read(wxString *filename) if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) continue ; - wxString file( m_name ) ; - if ( m_filespec.IsEmpty() || m_filespec == "*.*" || m_filespec == "*" ) + wxString file = wxMacMakeStringFromPascal( m_name ) ; + if ( m_filespec.IsEmpty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") ) { } - else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" ) + else if ( m_filespec.Length() > 1 && m_filespec.Left(1) == wxT("*") ) { if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() ) { continue ; } } - else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" ) + else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == wxT("*") ) { if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() ) { @@ -226,7 +217,7 @@ bool wxDirData::Read(wxString *filename) return FALSE ; } - *filename = (char*) m_name ; + *filename = wxMacMakeStringFromPascal( m_name ) ; return TRUE; } @@ -270,12 +261,12 @@ 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); - } + name = M_DIR->GetName(); + if ( !name.empty() && (name.Last() == _T('/')) ) + { + // chop off the last (back)slash + name.Truncate(name.length() - 1); + } } return name;