/
sandbox_p.h
62 lines (50 loc) · 1.37 KB
/
sandbox_p.h
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
/**
* @file sandbox_p.h
* @copyright 2013 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2013
*/
#ifndef _SANDBOX_P_H
#define _SANDBOX_P_H
#include <QtCore/QDir>
#include <QtCore/QSet>
#include <QtCore/QString>
class Sandbox {
public:
enum Usage {
UseDirectly,
UseAsSkeleton,
};
enum Scope {
ThisProcess = 0x01,
ChildProcesses = 0x02,
};
Q_DECLARE_FLAGS(Scopes, Scope)
public:
Sandbox();
Sandbox(const QString &sandboxPath, Usage usage, Scopes scopes);
~Sandbox();
bool activate();
void deactivate();
bool isActive() const;
static QDir effectiveRootDir();
static QString map(const QString &fileName);
bool addWorldFiles(const QString &directory, QDir::Filters filters = QDir::NoFilter,
const QStringList &filterNames = QStringList(), bool recurse = true);
bool addWorldFile(const QString &file);
private:
bool prepare();
static QString createTmpDir(const QString &nameTemplate);
static bool copyDir(const QString &directory, const QString &newName);
private:
static Sandbox *s_activeInstance;
const bool m_defaultConstructed;
const Usage m_usage;
const Scopes m_scopes;
const QString m_sandboxPath;
bool m_prepared;
QString m_tempDir;
QDir m_workingSandboxDir;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Sandbox::Scopes)
#endif