]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/dir.cpp
mac changes : wxDC - removed doubly defined vars (inherited from base) and fixed...
[wxWidgets.git] / src / mac / dir.cpp
index ec94a4e1ec5f0216a21113491258943ccb740bfd..e37f079382775a1b9c33eec893a53c7b5efd6290 100644 (file)
 #include "wx/dir.h"
 #include "wx/filefn.h"          // for wxPathExists()
 
-#include <windows.h>
-
-#ifdef __WXMAC__
+#ifndef __WXMAC_X__
+  #include <windows.h>
+#endif
 
-#include "morefile.h"
-#include "moreextr.h"
-#include "fullpath.h"
-#include "fspcompa.h"
+#if defined(__WXMAC__) && !defined(__UNIX__)
+  #include "morefile.h"
+  #include "moreextr.h"
+  #include "fullpath.h"
+  #include "fspcompa.h"
 #endif
 
 // ----------------------------------------------------------------------------
@@ -116,8 +117,12 @@ wxDirData::wxDirData(const wxString& dirname)
        m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
        m_CPB.hFileInfo.ioNamePtr = m_name ;
        m_index = 0 ;
-       
+
+#ifdef __WXMAC_X__
+       // TODO: what are we supposed to do for Mac OS X
+#else
        FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
+#endif
 }
 
 wxDirData::~wxDirData()
@@ -131,9 +136,12 @@ void wxDirData::Rewind()
 
 bool wxDirData::Read(wxString *filename)
 {
-       if ( !m_isDir )
-               return FALSE ;
+    if ( !m_isDir )
+        return FALSE ;
                
+#if TARGET_CARBON
+       char c_name[256] ;
+#endif
     wxString result;
 
        short err = noErr ;
@@ -146,7 +154,13 @@ bool wxDirData::Read(wxString *filename)
                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
                if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) //  we have a directory
                        break ;
                        
@@ -156,17 +170,37 @@ bool wxDirData::Read(wxString *filename)
         if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
                        continue ;
 
+               wxString file( m_name ) ;
+               if ( m_filespec.IsEmpty() || m_filespec == "*.*" )
+               {
+               }
+               else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
+               {
+                       if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
+                       {
+                               continue ;
+                       }
+               }
+               else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
+               {
+                       if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
+                       {
+                               continue ;
+                       }
+               }
+               else if ( file.Upper() != m_filespec.Upper() )
+               {
+                       continue ;
+               }
+
                break ;
        }
        if ( err != noErr )
        {
                return FALSE ;
        }
-       FSSpec spec ;
-       
-       FSMakeFSSpecCompat(m_CPB.hFileInfo.ioVRefNum, m_dirId, m_name,&spec) ;
-                                                                 
-       *filename = wxMacFSSpec2UnixFilename( &spec ) ;
+
+       *filename = (char*) m_name ;
 
     return TRUE;
 }