mirror of
https://github.com/status-im/status-app.git
synced 2026-08-31 00:51:10 +00:00
feat: base_cpp
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#include "constants.h"
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
|
||||
// TODO: merge with constants from backend/
|
||||
|
||||
|
||||
QString Constants::applicationPath(QString path)
|
||||
{
|
||||
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + path).absoluteFilePath();
|
||||
}
|
||||
|
||||
QString Constants::tmpPath(QString path)
|
||||
{
|
||||
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + path).absoluteFilePath();
|
||||
}
|
||||
|
||||
QString Constants::cachePath(QString path)
|
||||
{
|
||||
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + path).absoluteFilePath();
|
||||
}
|
||||
|
||||
bool Constants::ensureDirectories()
|
||||
{
|
||||
if(Constants::applicationPath().isEmpty())
|
||||
{
|
||||
QDir d{Constants::applicationPath()};
|
||||
if(!d.mkpath(d.absolutePath()))
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setText("Cannot determine storage location");
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user