corrected findfirst/next on mac
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12279 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1448,18 +1448,25 @@ struct MacDirectoryIterator
|
|||||||
static int g_iter_flags ;
|
static int g_iter_flags ;
|
||||||
|
|
||||||
static MacDirectoryIterator g_iter ;
|
static MacDirectoryIterator g_iter ;
|
||||||
|
wxString g_iter_spec ;
|
||||||
|
|
||||||
wxString wxFindFirstFile(const wxChar *spec, int flags)
|
wxString wxFindFirstFile(const wxChar *spec, int flags)
|
||||||
{
|
{
|
||||||
wxString result;
|
wxString result;
|
||||||
|
|
||||||
|
g_iter_spec = spec ;
|
||||||
|
g_iter_spec.MakeUpper() ;
|
||||||
g_iter_flags = flags; /* MATTHEW: [5] Remember flags */
|
g_iter_flags = flags; /* MATTHEW: [5] Remember flags */
|
||||||
|
|
||||||
// Find path only so we can concatenate found file onto path
|
// Find path only so we can concatenate found file onto path
|
||||||
wxString path(wxPathOnly(spec));
|
wxString path(wxPathOnly(spec));
|
||||||
|
#ifdef __DARWIN__
|
||||||
|
// TODO:check whether is necessary/correct
|
||||||
if ( !path.IsEmpty() )
|
if ( !path.IsEmpty() )
|
||||||
result << path << wxT('\\');
|
result << path << wxT('/');
|
||||||
|
#else
|
||||||
|
result = path ;
|
||||||
|
#endif
|
||||||
FSSpec fsspec ;
|
FSSpec fsspec ;
|
||||||
|
|
||||||
wxMacFilename2FSSpec( result , &fsspec ) ;
|
wxMacFilename2FSSpec( result , &fsspec ) ;
|
||||||
@@ -1480,37 +1487,44 @@ wxString wxFindNextFile()
|
|||||||
wxString result;
|
wxString result;
|
||||||
|
|
||||||
short err = noErr ;
|
short err = noErr ;
|
||||||
|
wxString name ;
|
||||||
while ( err == noErr )
|
|
||||||
|
while(1)
|
||||||
{
|
{
|
||||||
g_iter.m_index++ ;
|
while ( err == noErr )
|
||||||
g_iter.m_CPB.dirInfo.ioFDirIndex = g_iter.m_index;
|
{
|
||||||
g_iter.m_CPB.dirInfo.ioDrDirID = g_iter.m_dirId; /* we need to do this every time */
|
g_iter.m_index++ ;
|
||||||
err = PBGetCatInfoSync((CInfoPBPtr)&g_iter.m_CPB);
|
g_iter.m_CPB.dirInfo.ioFDirIndex = g_iter.m_index;
|
||||||
if ( err != noErr )
|
g_iter.m_CPB.dirInfo.ioDrDirID = g_iter.m_dirId; /* we need to do this every time */
|
||||||
break ;
|
err = PBGetCatInfoSync((CInfoPBPtr)&g_iter.m_CPB);
|
||||||
|
if ( err != noErr )
|
||||||
|
break ;
|
||||||
|
|
||||||
if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (g_iter_flags & wxDIR) ) // we have a directory
|
if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (g_iter_flags & wxDIR) ) // we have a directory
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) )
|
if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) )
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
// hit !
|
// hit !
|
||||||
break ;
|
break ;
|
||||||
|
}
|
||||||
|
if ( err != noErr )
|
||||||
|
{
|
||||||
|
return wxEmptyString ;
|
||||||
|
}
|
||||||
|
FSSpec spec ;
|
||||||
|
|
||||||
|
FSMakeFSSpecCompat(g_iter.m_CPB.hFileInfo.ioVRefNum,
|
||||||
|
g_iter.m_dirId,
|
||||||
|
g_iter.m_name,
|
||||||
|
&spec) ;
|
||||||
|
|
||||||
|
wxString name = wxMacFSSpec2MacFilename( &spec ) ;
|
||||||
|
if ( g_iter_spec.Right(4)==(":*.*") || g_iter_spec.Right(2)==(":*") || name.Upper().Matches(g_iter_spec) )
|
||||||
|
return name ;
|
||||||
}
|
}
|
||||||
if ( err != noErr )
|
return wxEmptyString ;
|
||||||
{
|
|
||||||
return wxEmptyString ;
|
|
||||||
}
|
|
||||||
FSSpec spec ;
|
|
||||||
|
|
||||||
FSMakeFSSpecCompat(g_iter.m_CPB.hFileInfo.ioVRefNum,
|
|
||||||
g_iter.m_dirId,
|
|
||||||
g_iter.m_name,
|
|
||||||
&spec) ;
|
|
||||||
|
|
||||||
return wxMacFSSpec2MacFilename( &spec ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__WXMSW__)
|
#elif defined(__WXMSW__)
|
||||||
|
Reference in New Issue
Block a user