- while ( err == noErr )
- {
- g_iter.m_index++ ;
- 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 */
- 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
- break ;
-
- if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) )
- continue ;
-
- // hit !
- 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 ;
- }
- return wxEmptyString ;
-}
-
-#elif defined(__WXMSW__)
-
-#ifdef __WIN32__
- static HANDLE gs_hFileStruct = INVALID_HANDLE_VALUE;
- static WIN32_FIND_DATA gs_findDataStruct;
-#else // Win16
- #ifdef __BORLANDC__
- static struct ffblk gs_findDataStruct;
- #else
- static struct _find_t gs_findDataStruct;
- #endif // Borland
-#endif // Win32/16
-
-static wxString gs_strFileSpec;
-static int gs_findFlags = 0;
-
-wxString wxFindFirstFile(const wxChar *spec, int flags)
-{
- wxString result;
-
- gs_strFileSpec = spec;
- gs_findFlags = flags; /* MATTHEW: [5] Remember flags */
-
- // Find path only so we can concatenate found file onto path
- wxString path(wxPathOnly(gs_strFileSpec));
- if ( !path.IsEmpty() )
- result << path << wxT('\\');
-
-#ifdef __WIN32__
- if ( gs_hFileStruct != INVALID_HANDLE_VALUE )
- FindClose(gs_hFileStruct);
-
- gs_hFileStruct = ::FindFirstFile(WXSTRINGCAST spec, &gs_findDataStruct);
-
- if ( gs_hFileStruct == INVALID_HANDLE_VALUE )
- {
- result.Empty();
-
- return result;
- }
-
- bool isdir = !!(gs_findDataStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
-
- if (isdir && !(flags & wxDIR))
- return wxFindNextFile();
- else if (!isdir && flags && !(flags & wxFILE))
- return wxFindNextFile();
-
- result += gs_findDataStruct.cFileName;
-
- return result;
-#else // !Win32
- int flag = _A_NORMAL;
- if (flags & wxDIR)
- flag = _A_SUBDIR;
-
-#ifdef __BORLANDC__
- if (findfirst(WXSTRINGCAST spec, &gs_findDataStruct, flag) == 0)
-#else
- if (_dos_findfirst(WXSTRINGCAST spec, flag, &gs_findDataStruct) == 0)
-#endif
+ #if defined(_MSC_VER) || defined(__MINGW32__)
+ ok = _getcwd(cbuf, sz) != NULL;
+ #elif defined(__WXMAC__) && !defined(__DARWIN__)
+ FSSpec cwdSpec ;
+ FCBPBRec pb;
+ OSErr error;
+ Str255 fileName ;
+ pb.ioNamePtr = (StringPtr) &fileName;
+ pb.ioVRefNum = 0;
+ pb.ioRefNum = LMGetCurApRefNum();
+ pb.ioFCBIndx = 0;
+ error = PBGetFCBInfoSync(&pb);
+ if ( error == noErr )