Commit 589a2fec86756e061f370681957827985780d678

Authored by Scott Klum
2 parents 8748d391 a29b78a7

Merge branch 'master' of https://github.com/biometrics/openbr

Showing 1 changed file with 7 additions and 5 deletions
sdk/core/qtutils.cpp
... ... @@ -74,18 +74,20 @@ QStringList QtUtils::readLines(const QString &file)
74 74  
75 75 void QtUtils::readFile(const QString &file, QStringList &lines)
76 76 {
77   - QFile f(file);
78   - if (!f.open(QFile::ReadOnly)) qFatal("Unable to open %s for reading.", qPrintable(file));
79   - lines = QString(f.readAll()).split('\n', QString::SkipEmptyParts);
  77 + QByteArray data;
  78 + readFile(file, data);
  79 + lines = QString(data).split('\n', QString::SkipEmptyParts);
80 80 for (int i=0; i<lines.size(); i++)
81 81 lines[i] = lines[i].simplified();
82   - f.close();
83 82 }
84 83  
85 84 void QtUtils::readFile(const QString &file, QByteArray &data, bool uncompress)
86 85 {
87 86 QFile f(file);
88   - if (!f.open(QFile::ReadOnly)) qFatal("Unable to open %s for reading.", qPrintable(file));
  87 + if (!f.open(QFile::ReadOnly)) {
  88 + if (f.exists()) qFatal("Unable to open %s for reading. Check file permissions.", qPrintable(file));
  89 + else qFatal("Unable to open %s for reading. File does not exist.", qPrintable(file));
  90 + }
89 91 data = f.readAll();
90 92 if (uncompress) data = qUncompress(data);
91 93 f.close();
... ...