wxdirtraverserwxdirtraverser is an abstract interface which must be implemented by objects passed to traverse function. example of use (this works almost like getallfiles):
class wxdirtraversersimple : public wxdirtraverser { public: wxdirtraversersimple(wxarraystring& files) : m_files(files) { } virtual wxdirtraverseresult onfile(const wxstring& filename) { m_files.add(filename); return wxdir_continue; } virtual wxdirtraverseresult ondir(const wxstring& wxunused(dirname)) { return wxdir_continue; } private: wxarraystring& m_files; }; // get the names of all files in the array wxarraystring files; wxdirtraversersimple traverser(files); wxdir dir(dirname); dir.traverse(traverser);derived from no base class constants the elements of wxdirtraverseresult are the possible return values of the callback functions:
include files <wx/dir.h> members
wxdirtraverser::ondir
wxdirtraverser::ondirvirtual wxdirtraverseresult ondir(const wxstring& dirname) this function is called for each directory. it may return wxsir_stop to abort traversing completely, wxdir_ignore to skip this directory but continue with others or wxdir_continue to enumerate all files and subdirectories in this directory. this is a pure virtual function and must be implemented in the derived class.
wxdirtraverser::onfilevirtual wxdirtraverseresult onfile(const wxstring& filename) this function is called for each file. it may return wxdir_stop to abort traversing (for example, if the file being searched is found) or wxdir_continue to proceed. this is a pure virtual function and must be implemented in the derived class.
wxdirtraverser::onopenerrorvirtual wxdirtraverseresult onopenerror(const wxstring& openerrorname) this function is called for each directory which we failed to open for enumerating. it may return wxsir_stop to abort traversing completely, wxdir_ignore to skip this directory but continue with others or wxdir_continue to retry opening this directory once again. the base class version always returns wxdir_ignore.
|