wxFindFirstFile and friends for wxMGL
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
abb855613b
commit
8ff1234234
@ -33,6 +33,7 @@
|
||||
#include "wx/intl.h"
|
||||
#include "wx/file.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/dir.h"
|
||||
|
||||
// there are just too many of those...
|
||||
#ifdef __VISUALC__
|
||||
@ -1717,6 +1718,58 @@ wxString wxFindNextFile()
|
||||
return result;
|
||||
}
|
||||
|
||||
#else // generic implementation:
|
||||
|
||||
static wxDir *gs_dir = NULL;
|
||||
static wxString gs_dirPath;
|
||||
|
||||
wxString wxFindFirstFile(const wxChar *spec, int flags)
|
||||
{
|
||||
gs_dirPath = wxPathOnly(spec);
|
||||
if ( gs_dirPath.IsEmpty() )
|
||||
gs_dirPath = wxT(".");
|
||||
if ( gs_dirPath.Last() != wxFILE_SEP_PATH )
|
||||
gs_dirPath << wxFILE_SEP_PATH;
|
||||
|
||||
if (gs_dir)
|
||||
delete gs_dir;
|
||||
gs_dir = new wxDir(gs_dirPath);
|
||||
|
||||
if ( !gs_dir->IsOpened() )
|
||||
{
|
||||
wxLogSysError(_("Can not enumerate files '%s'"), spec);
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
int dirFlags = 0;
|
||||
switch (flags)
|
||||
{
|
||||
case wxDIR: dirFlags = wxDIR_DIRS; break;
|
||||
case wxFILE: dirFlags = wxDIR_FILES; break;
|
||||
default: dirFlags = wxDIR_DIRS | wxDIR_FILES; break;
|
||||
}
|
||||
|
||||
wxString result;
|
||||
gs_dir->GetFirst(&result, wxFileNameFromPath(spec), dirFlags);
|
||||
if ( result.IsEmpty() )
|
||||
wxDELETE(gs_dir);
|
||||
|
||||
return gs_dirPath + result;
|
||||
}
|
||||
|
||||
wxString wxFindNextFile()
|
||||
{
|
||||
wxASSERT_MSG( gs_dir, wxT("You must call wxFindFirstFile before!") );
|
||||
|
||||
wxString result;
|
||||
gs_dir->GetNext(&result);
|
||||
|
||||
if ( result.IsEmpty() )
|
||||
wxDELETE(gs_dir);
|
||||
|
||||
return gs_dirPath + result;
|
||||
}
|
||||
|
||||
#endif // Unix/Windows/OS/2
|
||||
|
||||
// Get current working directory.
|
||||
|
Loading…
Reference in New Issue
Block a user