]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/dirmac.cpp
Fix conversion error in tooltips.
[wxWidgets.git] / src / mac / dirmac.cpp
index 9ea9415df48423cec0c40edba9b8af9045c6b541..0afc3b5cb3449184dcb1617631f138ce79d80ad0 100644 (file)
@@ -81,6 +81,7 @@ public:
     void Rewind() ;
 
     const wxString& GetName() const { return m_dirname; }
+    bool Ok() const { return m_ok; }
 
 private:
     CInfoPBRec            m_CPB ;
@@ -93,6 +94,7 @@ private:
     wxString m_filespec;
 
     int      m_flags;
+    bool     m_ok;
 };
 
 // ============================================================================
@@ -106,6 +108,8 @@ private:
 wxDirData::wxDirData(const wxString& dirname)
          : m_dirname(dirname)
 {
+    m_ok = false;
+    
     OSErr err;
     
     // throw away the trailing slashes
@@ -133,7 +137,11 @@ 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)) ;
+    if ( (err == noErr) || (err == nsvErr))
+        m_ok = true;
+    else
+        wxLogError(wxString(wxT("Error accessing directory ")) + m_dirname);
 
     m_CPB.hFileInfo.ioNamePtr = m_name ;
     m_index = 0 ;
@@ -153,9 +161,6 @@ bool wxDirData::Read(wxString *filename)
     if ( !m_isDir )
         return FALSE ;
         
-#if TARGET_CARBON
-    char c_name[256] ;
-#endif
     wxString result;
 
     short err = noErr ;
@@ -169,18 +174,12 @@ bool wxDirData::Read(wxString *filename)
         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 +195,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 +225,7 @@ bool wxDirData::Read(wxString *filename)
         return FALSE ;
     }
     
-    *filename = (char*) m_name ;
+    *filename = wxMacMakeStringFromPascal( m_name )  ;
 
     return TRUE;
 }
@@ -256,8 +255,14 @@ bool wxDir::Open(const wxString& dirname)
 {
     delete M_DIR;
     m_data = new wxDirData(dirname);
-
-    return TRUE;
+    if (m_data->Ok())
+        return TRUE;
+    else
+    {
+        delete m_data;
+        m_data = NULL;
+        return FALSE;
+    }
 }
 
 bool wxDir::IsOpened() const