blob: b8fdac8b0dde515a91755df8a4286e8474edc21f (
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
|
#ifndef FSROWS_H
#define FSROWS_H
#include <filesystem>
#include <sys/stat.h>
#include "variables.h"
#include "rowSet.h"
#include "scriptStorage.h"
#include "scriptLoader.h"
#include <factory.h>
class CommonObjects;
/// Project2 component to create a row set based on files and directories on the local filesystem
class DLL_PUBLIC FsRows : public RowSet {
public:
class SearchState;
class SpecBase : public virtual Something {
public:
virtual bool recurse(const SearchState * fs, ExecContext *) const;
virtual bool matches(const SearchState * fs, ExecContext *) const;
protected:
const std::filesystem::path & curPath(const SearchState * fs) const;
unsigned int depth(const SearchState * fs) const;
const struct stat & curStat(const SearchState * fs) const;
};
typedef std::shared_ptr<SpecBase> SpecBasePtr;
typedef AdHoc::Factory<SpecBase, std::shared_ptr<const ScriptNode>> SpecBaseFactory;
typedef AdHoc::Factory<SpecBase, const Glib::ustring &> SpecBaseStringFactory;
typedef ANONSTORAGEOF(SpecBase) SpecBases;
typedef std::list<Glib::ustring> SpecSpec;
typedef std::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 std::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 std::filesystem::path fsRoot;
std::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
|