2019-04-06 17:16:42 +02:00
|
|
|
#include <QDebug>
|
|
|
|
#include "utils.h"
|
|
|
|
Utils::Utils()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Utils::readFile(QString path)
|
|
|
|
{
|
|
|
|
QFile file(path);
|
|
|
|
if(!file.open(QIODevice::ReadOnly))
|
|
|
|
{
|
2021-06-12 14:59:58 +02:00
|
|
|
throw LooqsGeneralException("Failed to open file: " + path);
|
2019-04-06 17:16:42 +02:00
|
|
|
}
|
|
|
|
QByteArray data = file.readAll();
|
|
|
|
if(data.isEmpty() && file.error() != QFileDevice::FileError::NoError)
|
|
|
|
{
|
2021-06-12 14:59:58 +02:00
|
|
|
throw LooqsGeneralException("Error reading file: " + path + ", Error: " + file.error());
|
2019-04-06 17:16:42 +02:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|