|
ssu
|
Helps to redirect file operations into sandbox directory. More...
Public Types | |
| enum | Usage { UseDirectly , UseAsSkeleton } |
| enum | Scope { ThisProcess = 0x01 , ChildProcesses = 0x02 } |
Public Member Functions | |
| Sandbox (const QString &sandboxPath, Usage usage, Scopes scopes) | |
| bool | activate () |
| void | deactivate () |
| bool | isActive () const |
| bool | addWorldFiles (const QString &directory, QDir::Filters filters=QDir::NoFilter, const QStringList &filterNames=QStringList(), bool recurse=true) |
| bool | addWorldFile (const QString &file) |
Static Public Member Functions | |
| static QDir | effectiveRootDir () |
| static QString | map (const QString &fileName) |
| static QString | map (const QString &pathName, const QString &fileName) |
Helps to redirect file operations into sandbox directory.
The term world files is used to reffer files outside sandbox.
To write a sandbox aware code, simply use the map() function to process paths before accessing them.
Its effect is controlled by activate() and deactivate() calls. Only one Sandbox instance can be active at any time. Active sandbox is automatically deactivated upon destruction.
When constructed without arguments, path to sandbox directory is get from SSU_SANDBOX_DIR environment variable.
qFatal(), i.e., application will be abort()ed.When constructed with usage UseAsSkeleton, it will first make temporary copy of sandboxPath to work on and files in the original directory will stay untouched. Also see addWorldFiles().
The argument @scopes allows to control if the sandbox will be used by this process, its children processes (SSU_SANDBOX_DIR environment variable will be exported), or both.
Definition at line 21 of file sandbox_p.h.
| enum Sandbox::Scope |
Definition at line 29 of file sandbox_p.h.
| enum Sandbox::Usage |
Definition at line 24 of file sandbox_p.h.
| Sandbox::Sandbox | ( | ) |
Definition at line 58 of file sandbox.cpp.
| Sandbox::Sandbox | ( | const QString & | sandboxPath, |
| Usage | usage, | ||
| Scopes | scopes ) |
Definition at line 68 of file sandbox.cpp.
| Sandbox::~Sandbox | ( | ) |
Definition at line 75 of file sandbox.cpp.
| bool Sandbox::activate | ( | ) |
Definition at line 93 of file sandbox.cpp.
| bool Sandbox::addWorldFile | ( | const QString & | file | ) |
Definition at line 227 of file sandbox.cpp.
| bool Sandbox::addWorldFiles | ( | const QString & | directory, |
| QDir::Filters | filters = QDir::NoFilter, | ||
| const QStringList & | filterNames = QStringList(), | ||
| bool | recurse = true ) |
Copies selected files into sandbox. Existing files in sandbox are not overwriten.
QDir::NoDotAndDotDot is always added into filters.
Definition at line 146 of file sandbox.cpp.
| void Sandbox::deactivate | ( | ) |
Definition at line 109 of file sandbox.cpp.
|
static |
Definition at line 120 of file sandbox.cpp.
| bool Sandbox::isActive | ( | ) | const |
Definition at line 88 of file sandbox.cpp.
|
static |
Definition at line 127 of file sandbox.cpp.
|
static |
Definition at line 134 of file sandbox.cpp.