blob: 2e44750e0966f66c57ffd358621fdda581cb9dea (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#ifndef FSROWS_H
#define FSROWS_H
#include <boost/intrusive_ptr.hpp>
#include <boost/filesystem/path.hpp>
#include <sys/stat.h>
#include "variables.h"
#include "rowSet.h"
#include "scriptStorage.h"
#include "scriptLoader.h"
class CommonObjects;
/// Project2 component to create a row set based on files and directories on the local filesystem
class FsRows : public RowSet {
public:
class SearchState;
class SpecBase : public virtual IntrusivePtrBase {
public:
virtual bool recurse(const SearchState * fs, ExecContext *) const;
virtual bool matches(const SearchState * fs, ExecContext *) const;
protected:
const boost::filesystem::path & curPath(const SearchState * fs) const;
unsigned int depth(const SearchState * fs) const;
const struct stat & curStat(const SearchState * fs) const;
};
typedef boost::intrusive_ptr<SpecBase> SpecBasePtr;
template <class X>
class SpecBaseLoaderX : public GenLoader<SpecBase, std::string, ScriptNodePtr> {
public:
virtual SpecBase * createWith(const Glib::ustring &) const = 0;
template <class T, class BaseLoader = SpecBaseLoaderX<X>>
class For : public BaseLoader {
public:
inline SpecBase * create(const ScriptNodePtr & v) const {
return new T(v);
}
inline SpecBase * createWith(const Glib::ustring & v) const {
return new T(v);
}
};
};
typedef SpecBaseLoaderX<void> SpecBaseLoader;
typedef ANONSTORAGEOF(SpecBase) SpecBases;
typedef std::list<Glib::ustring> SpecSpec;
typedef boost::filesystem::path Path;
FsRows(ScriptNodePtr p);
~FsRows();
const Variable root;
const Variable spec;
const Variable ignoreErrors;
void execute(const Glib::ustring &, const RowProcessorCallback &, ExecContext *) const;
class SearchState : public RowState {
public:
SearchState(const boost::filesystem::path & r);
virtual RowAttribute resolveAttr(const Glib::ustring & attrName) const;
virtual void foreachAttr(const AttrAction & action) const;
virtual const Columns & getColumns() const;
VariableType fileRelPath() const;
VariableType fileSize() const;
VariableType fileModDate() const;
VariableType fileUser() const;
VariableType fileGroup() const;
VariableType fileMode() const;
VariableType filePerms() const;
VariableType fileType() const;
static const Columns col;
SpecBases specs;
const boost::filesystem::path fsRoot;
boost::filesystem::path curPath;
Glib::ustring curPathStr;
unsigned int depth;
struct stat curStat;
};
protected:
void execute(SearchState &, const Path & dir, const RowProcessorCallback &, ExecContext *) const;
friend class SpecBase;
SpecBases specs;
};
#endif
|