| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2008 by Eran Ifrah |
| 5 |
// file name : dirtraverser.h |
| 6 |
// |
| 7 |
// ------------------------------------------------------------------------- |
| 8 |
// A |
| 9 |
// _____ _ _ _ _ |
| 10 |
// / __ \ | | | | (_) | |
| 11 |
// | / \/ ___ __| | ___| | _| |_ ___ |
| 12 |
// | | / _ \ / _ |/ _ \ | | | __/ _ ) |
| 13 |
// | \__/\ (_) | (_| | __/ |___| | || __/ |
| 14 |
// \____/\___/ \__,_|\___\_____/_|\__\___| |
| 15 |
// |
| 16 |
// F i l e |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
////////////////////////////////////////////////////////////////////////////// |
| 24 |
////////////////////////////////////////////////////////////////////////////// |
| 25 |
#ifndef DIRTRAVERSER_H |
| 26 |
#define DIRTRAVERSER_H |
| 27 |
|
| 28 |
#include "codelite_exports.h" |
| 29 |
#include <wx/dir.h> |
| 30 |
#include <wx/arrstr.h> |
| 31 |
#include <map> |
| 32 |
|
| 33 |
/** |
| 34 |
* A helper class that help us recurse into sub-directories. |
| 35 |
* For each found directory, sink.OnDir() is called and sink.OnFile() is called for every file. |
| 36 |
* Depending on the return value, the enumeration may continue or stop of one of the files, the |
| 37 |
* recurse may stop. |
| 38 |
* \ingroup CodeLite |
| 39 |
* \version 1.0 |
| 40 |
* first version |
| 41 |
* \date 11-08-2006 |
| 42 |
* \author Eran |
| 43 |
*/ |
| 44 |
class WXDLLIMPEXP_CL DirTraverser : public wxDirTraverser |
| 45 |
{ |
| 46 |
wxArrayString m_files; |
| 47 |
wxString m_filespec; |
| 48 |
wxArrayString m_specArray; |
| 49 |
|
| 50 |
bool m_extlessFiles; |
| 51 |
wxArrayString m_excludeDirs; |
| 52 |
|
| 53 |
public: |
| 54 |
|
| 55 |
/** |
| 56 |
* Construct a DirTraverser with a given file spec |
| 57 |
*/ |
| 58 |
DirTraverser(const wxString &filespec, bool includExtLessFiles = false); |
| 59 |
virtual ~DirTraverser(); |
| 60 |
|
| 61 |
/** |
| 62 |
* This function is called once a file is found. The traverse of the directories |
| 63 |
* can be stopped based on the return value from this function: |
| 64 |
* - wxDIR_IGNORE = -1, // ignore this directory but continue with others |
| 65 |
* - wxDIR_STOP, // stop traversing |
| 66 |
* - wxDIR_CONTINUE // continue into this directory |
| 67 |
* \param filename name of the file that was found |
| 68 |
* \return one of the values wxDIR_STOP, wxDIR_IGNORE or wxDIR_CONTINUE |
| 69 |
*/ |
| 70 |
virtual wxDirTraverseResult OnFile(const wxString& filename); |
| 71 |
|
| 72 |
/** |
| 73 |
* This function is called once a directory is found. The traverse of the directories |
| 74 |
* can be stopped based on the return value from this function: |
| 75 |
* - wxDIR_IGNORE = -1, // ignore this directory but continue with others |
| 76 |
* - wxDIR_STOP, // stop traversing |
| 77 |
* - wxDIR_CONTINUE // continue into this directory |
| 78 |
* \param dirname name of the directory that was found |
| 79 |
* \return one of the values wxDIR_STOP, wxDIR_IGNORE or wxDIR_CONTINUE |
| 80 |
*/ |
| 81 |
virtual wxDirTraverseResult OnDir(const wxString& dirname); |
| 82 |
|
| 83 |
void SetExcludeDirs(const wxArrayString& excludeDirs) { |
| 84 |
this->m_excludeDirs = excludeDirs; |
| 85 |
} |
| 86 |
const wxArrayString& GetExcludeDirs() const { |
| 87 |
return m_excludeDirs; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Return list of files found |
| 92 |
* \return Return list of files found |
| 93 |
*/ |
| 94 |
wxArrayString& GetFiles() { |
| 95 |
return m_files; |
| 96 |
} |
| 97 |
}; |
| 98 |
|
| 99 |
#endif //DIRTRAVERSER_H |