forked from wghost/UPKUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileUtils.h
44 lines (39 loc) · 1.03 KB
/
FileUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef FILEUTILS_H
#define FILEUTILS_H
#include <wx/string.h>
#include <wx/filefn.h>
#include <wx/filename.h>
#include <wx/dir.h>
int _CRT_glob = 0; /// prevent wildcard expansion of command line arguments
class wxDirTraverserSimple : public wxDirTraverser
{
public:
wxDirTraverserSimple(wxArrayString& files, wxString fileMask = "*") : m_files(files), match(fileMask) {}
virtual wxDirTraverseResult OnFile(const wxString& filename)
{
if (wxMatchWild(match, filename, false))
m_files.Add(filename);
return wxDIR_CONTINUE;
}
virtual wxDirTraverseResult OnDir(const wxString& WXUNUSED(dirname))
{
return wxDIR_CONTINUE;
}
private:
wxArrayString& m_files;
wxString match = "*";
};
wxArrayString TraverseDir(wxString dirName, wxString mask)
{
wxArrayString res;
if (wxIsWild(mask))
{
wxDirTraverserSimple traverser(res, mask);
wxDir dir(dirName);
dir.Traverse(traverser);
}
else
res.Add(mask);
return res;
}
#endif //FILEUTILS_H