diff options
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/library/qmakeparser.cpp | 5 | ||||
-rw-r--r-- | qmake/library/qmakevfs.cpp | 21 | ||||
-rw-r--r-- | qmake/library/qmakevfs.h | 8 |
3 files changed, 21 insertions, 13 deletions
diff --git a/qmake/library/qmakeparser.cpp b/qmake/library/qmakeparser.cpp index b5d89c1ba6..62e8875c5e 100644 --- a/qmake/library/qmakeparser.cpp +++ b/qmake/library/qmakeparser.cpp @@ -254,8 +254,9 @@ bool QMakeParser::read(ProFile *pro, ParseFlags flags) { QString content; QString errStr; - if (!m_vfs->readFile(pro->fileName(), &content, &errStr)) { - if (m_handler && ((flags & ParseReportMissing) || m_vfs->exists(pro->fileName()))) + QMakeVfs::ReadResult result = m_vfs->readFile(pro->fileName(), &content, &errStr); + if (result != QMakeVfs::ReadOk) { + if (m_handler && ((flags & ParseReportMissing) || result != QMakeVfs::ReadNotFound)) m_handler->message(QMakeParserHandler::ParserIoError, fL1S("Cannot read %1: %2").arg(pro->fileName(), errStr)); return false; diff --git a/qmake/library/qmakevfs.cpp b/qmake/library/qmakevfs.cpp index 5aa9ec9299..7631723b1b 100644 --- a/qmake/library/qmakevfs.cpp +++ b/qmake/library/qmakevfs.cpp @@ -100,7 +100,7 @@ bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, bool exe, #endif } -bool QMakeVfs::readFile(const QString &fn, QString *contents, QString *errStr) +QMakeVfs::ReadResult QMakeVfs::readFile(const QString &fn, QString *contents, QString *errStr) { #ifndef PROEVALUATOR_FULL # ifdef PROEVALUATOR_THREAD_SAFE @@ -110,25 +110,26 @@ bool QMakeVfs::readFile(const QString &fn, QString *contents, QString *errStr) if (it != m_files.constEnd()) { if (it->constData() == m_magicMissing.constData()) { *errStr = fL1S("No such file or directory"); - return false; + return ReadNotFound; } if (it->constData() != m_magicExisting.constData()) { *contents = *it; - return true; + return ReadOk; } } #endif QFile file(fn); if (!file.open(QIODevice::ReadOnly)) { + if (!file.exists()) { #ifndef PROEVALUATOR_FULL - if (!IoUtils::exists(fn)) { m_files[fn] = m_magicMissing; - *errStr = fL1S("No such file or directory"); - } else #endif - *errStr = file.errorString(); - return false; + *errStr = fL1S("No such file or directory"); + return ReadNotFound; + } + *errStr = file.errorString(); + return ReadOtherError; } #ifndef PROEVALUATOR_FULL m_files[fn] = m_magicExisting; @@ -138,10 +139,10 @@ bool QMakeVfs::readFile(const QString &fn, QString *contents, QString *errStr) if (bcont.startsWith("\xef\xbb\xbf")) { // UTF-8 BOM will cause subtle errors *errStr = fL1S("Unexpected UTF-8 BOM"); - return false; + return ReadOtherError; } *contents = QString::fromLocal8Bit(bcont); - return true; + return ReadOk; } bool QMakeVfs::exists(const QString &fn) diff --git a/qmake/library/qmakevfs.h b/qmake/library/qmakevfs.h index 8677ba08c1..5e6a2f88e2 100644 --- a/qmake/library/qmakevfs.h +++ b/qmake/library/qmakevfs.h @@ -45,10 +45,16 @@ QT_BEGIN_NAMESPACE class QMAKE_EXPORT QMakeVfs { public: + enum ReadResult { + ReadOk, + ReadNotFound, + ReadOtherError + }; + QMakeVfs(); bool writeFile(const QString &fn, QIODevice::OpenMode mode, bool exe, const QString &contents, QString *errStr); - bool readFile(const QString &fn, QString *contents, QString *errStr); + ReadResult readFile(const QString &fn, QString *contents, QString *errStr); bool exists(const QString &fn); #ifndef PROEVALUATOR_FULL |