looqs/shared/utils.cpp

21 righe
461 B
C++

#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);
}
QByteArray data = file.readAll();
if(data.isEmpty() && file.error() != QFileDevice::FileError::NoError)
{
2024-05-20 19:14:40 +02:00
throw LooqsGeneralException("Error reading file: " + path + ", Error: " + QString::number(file.error()));
}
return data;
}