File: clFilesCollector.h

package info (click to toggle)
codelite 14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (54 lines) | stat: -rw-r--r-- 1,812 bytes parent folder | download
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
45
46
47
48
49
50
51
52
53
54
#ifndef CLFILESCOLLECTOR_H
#define CLFILESCOLLECTOR_H

#include "codelite_exports.h"
#include "macros.h"
#include <vector>
#include <wx/string.h>
#include <wx/filename.h>

class WXDLLIMPEXP_CL clFilesScanner
{
public:
    struct EntryData {
        size_t flags = 0;
        wxString fullpath;
        typedef std::vector<EntryData> Vec_t;
    };

    enum eFileAttributes {
        kInvalid = 0,
        kIsFile = (1 << 0),
        kIsFolder = (1 << 1),
        kIsHidden = (1 << 2),
        kIsSymlink = (1 << 3),
    };

public:
    clFilesScanner();
    virtual ~clFilesScanner();

    /**
     * @brief collect all files matching a given pattern from a root folder
     * @param rootFolder the scan root folder
     * @param filesOutput [output] output result full path entries
     * @param filespec files spec
     * @param excludeFolders list of folder to exclude from the search
     * @return number of files found
     */
    size_t Scan(const wxString& rootFolder, std::vector<wxString>& filesOutput, const wxString& filespec = "*",
                const wxString& excludeFilespec = "", const wxStringSet_t& excludeFolders = wxStringSet_t());
    /**
     * @brief same as above, but accepts the ignore directories list in a spec format
     */
    size_t Scan(const wxString& rootFolder, std::vector<wxFileName>& filesOutput, const wxString& filespec,
                const wxString& excludeFilespec, const wxString& excludeFoldersSpec);
    /**
     * @brief scan folder for files and folders. This function does not recurse into folders. Everything that matches
     * "matchSpec" will get collected.
     */
    size_t ScanNoRecurse(const wxString& rootFolder, clFilesScanner::EntryData::Vec_t& results,
                         const wxString& matchSpec = "*");
};

#endif // CLFILESCOLLECTOR_H