diff --git a/src/SeerUtl.cpp b/src/SeerUtl.cpp index 0e2d8a6..e5483e3 100644 --- a/src/SeerUtl.cpp +++ b/src/SeerUtl.cpp @@ -1,4 +1,5 @@ #include "SeerUtl.h" +#include #include #include @@ -506,5 +507,29 @@ namespace Seer { return 0; } } + + bool readFile (const QString& filename, QStringList& lines) { + + // Empty the list + lines = QStringList(); + + // Open the file. + QFile file(filename); + + if (file.open(QIODevice::ReadOnly) == false) { + qDebug() << "Can't open:" << filename; + return false; + } + + // Read the file line-by-line and build up the string list. + while (file.atEnd() == false) { + lines.append(file.readLine()); + } + + file.close(); + + // All good. + return true; + } } diff --git a/src/SeerUtl.h b/src/SeerUtl.h index cde7519..eeac49f 100644 --- a/src/SeerUtl.h +++ b/src/SeerUtl.h @@ -25,5 +25,7 @@ namespace Seer { unsigned char ucharToAscii (unsigned char byte); int typeBytes (const QString& type); + + bool readFile (const QString& filename, QStringList& lines); }