This commit is contained in:
tobtoht
2021-05-02 20:22:38 +02:00
parent e6f512788b
commit d4cfa05157
152 changed files with 6060 additions and 1880 deletions
+18
View File
@@ -21,6 +21,24 @@
QVector<logMessage> applicationLog = QVector<logMessage>(); // todo: replace with ring buffer
QMutex logMutex;
QByteArray Utils::fileGetContents(const QString &path)
{
QFile file(path);
if (!file.open(QFile::ReadOnly))
{
throw std::runtime_error(QString("failed to open %1").arg(path).toStdString());
}
QByteArray data;
data.resize(file.size());
if (file.read(data.data(), data.size()) != data.size())
{
throw std::runtime_error(QString("failed to read %1").arg(path).toStdString());
}
return data;
}
bool Utils::fileExists(const QString &path) {
QFileInfo check_file(path);
return check_file.exists() && check_file.isFile();