aboutsummaryrefslogtreecommitdiff
path: root/src/qt/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/utils.cpp')
-rw-r--r--src/qt/utils.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/qt/utils.cpp b/src/qt/utils.cpp
index bcf69917..258400c3 100644
--- a/src/qt/utils.cpp
+++ b/src/qt/utils.cpp
@@ -37,6 +37,24 @@ bool fileExists(QString path) {
return check_file.exists() && check_file.isFile();
}
+QByteArray fileGetContents(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;
+}
+
QByteArray fileOpen(QString path) {
QFile file(path);
if(!file.open(QFile::ReadOnly | QFile::Text))