Commit a5e22aa5 authored by Martin Kampas's avatar Martin Kampas

Sandbox: overlay any file found in sandbox

Up to now the list of files to overlay was fixed/hardcoded.
parent 48ee9cf9
......@@ -50,15 +50,6 @@ class Sandbox::FileEngineHandler : public QAbstractFileEngineHandler {
Sandbox *Sandbox::s_instance = 0;
QSet<QString> Sandbox::s_ssuConfigFiles = QSet<QString>()
<< SSU_CONFIGURATION
<< SSU_REPO_CONFIGURATION
<< SSU_DEFAULT_CONFIGURATION
<< SSU_BOARD_MAPPING_CONFIGURATION;
QSet<QString> Sandbox::s_ssuConfigDirectories = QSet<QString>()
<< SSU_BOARD_MAPPING_CONFIGURATION_DIR;
Sandbox::Sandbox(){
if (s_instance != 0){
qFatal("%s: Cannot be instantiated more than once", Q_FUNC_INFO);
......@@ -171,20 +162,19 @@ QAbstractFileEngine *Sandbox::FileEngineHandler::create(const QString &fileName)
return 0;
}
if (!s_ssuConfigFiles.contains(fileName)){
bool match = false;
foreach (const QString &ssuConfigDirectory, s_ssuConfigDirectories){
if (fileName.startsWith(ssuConfigDirectory + '/')){
match = true;
break;
}
}
if (!match){
return 0;
}
const QString sandboxedFileName = m_sandboxPath + fileName;
QScopedPointer<QFSFileEngine> sandboxedFileEngine(new QFSFileEngine(sandboxedFileName));
const QAbstractFileEngine::FileFlags flags = sandboxedFileEngine->fileFlags(
QAbstractFileEngine::ExistsFlag | QAbstractFileEngine::DirectoryType);
if (!(flags & QAbstractFileEngine::ExistsFlag)){
return 0;
}
const QString fileName_ = QDir(m_sandboxPath).absoluteFilePath(QString(fileName).remove(0, 1));
if (flags & QAbstractFileEngine::DirectoryType){
return 0;
}
return new QFSFileEngine(fileName_);
return sandboxedFileEngine.take();
}
......@@ -8,7 +8,6 @@
#ifndef _SANDBOX_P_H
#define _SANDBOX_P_H
#include <QtCore/QSet>
#include <QtCore/QString>
class Sandbox {
......@@ -33,8 +32,6 @@ class Sandbox {
private:
static Sandbox *s_instance;
static QSet<QString> s_ssuConfigFiles;
static QSet<QString> s_ssuConfigDirectories;
QString m_sandboxPath;
QString m_tempDir;
FileEngineHandler *m_handler;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment