cli: Move most classes to shared lib for reuse

This commit is contained in:
2022-03-18 22:33:45 +01:00
parent d43c35819d
commit 478d57b342
33 changed files with 32 additions and 44 deletions

20
shared/utils.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include <QDebug>
#include "utils.h"
Utils::Utils()
{
}
QByteArray Utils::readFile(QString path)
{
QFile file(path);
if(!file.open(QIODevice::ReadOnly))
{
throw LooqsGeneralException("Failed to open file: " + path);
}
QByteArray data = file.readAll();
if(data.isEmpty() && file.error() != QFileDevice::FileError::NoError)
{
throw LooqsGeneralException("Error reading file: " + path + ", Error: " + file.error());
}
return data;
}