diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-01-24 12:52:38 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-02-02 18:43:40 +0100 |
commit | 747bca3d67b019d0a6a9ae3df8e6703463201fe4 (patch) | |
tree | afaf07cc1f8fe1d281cbaa6db5231e4f7d03c123 /qmake | |
parent | 31b8a7e5ed6d480e793082066ca55a4d1a3728e7 (diff) | |
download | qtbase-747bca3d67b019d0a6a9ae3df8e6703463201fe4.tar.gz |
qmake: Scan source files with QFile
The C API we've used so far underlies stronger restrictions regarding
path length than QFile. Since qmake is not bootstrapped anymore, we can
use QFile.
Task-number: QTBUG-99791
Change-Id: Ic7765b0c09a8aa07c208c1b1d02efe0c54bb44f2
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/generators/makefiledeps.cpp | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index b5a404de32..7ce47bdf72 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -29,6 +29,7 @@ #include "makefiledeps.h" #include "option.h" +#include <qfile.h> #include <qdir.h> #include <qdatetime.h> #include <qfileinfo.h> @@ -40,16 +41,8 @@ # include <io.h> #endif #include <qdebug.h> -#include <stdio.h> -#include <stdlib.h> #include <time.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/stat.h> #include <limits.h> -#if defined(_MSC_VER) && _MSC_VER >= 1400 -#include <share.h> -#endif QT_BEGIN_NAMESPACE @@ -515,28 +508,17 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file) const QMakeLocalFileName sourceFile = fixPathForFile(file->file, true); - struct stat fst; char *buffer = nullptr; int buffer_len = 0; { - int fd; -#if defined(_MSC_VER) && _MSC_VER >= 1400 - if (_sopen_s(&fd, sourceFile.local().toLatin1().constData(), - _O_RDONLY, _SH_DENYNO, _S_IREAD) != 0) - fd = -1; -#else - fd = open(sourceFile.local().toLatin1().constData(), O_RDONLY); -#endif - if (fd == -1 || fstat(fd, &fst) || S_ISDIR(fst.st_mode)) { - if (fd != -1) - QT_CLOSE(fd); + QFile f(sourceFile.local()); + if (!f.open(QIODevice::ReadOnly)) return false; - } - buffer = getBuffer(fst.st_size); + const qint64 fs = f.size(); + buffer = getBuffer(fs); for(int have_read = 0; - (have_read = QT_READ(fd, buffer + buffer_len, fst.st_size - buffer_len)); + (have_read = f.read(buffer + buffer_len, fs - buffer_len)); buffer_len += have_read) ; - QT_CLOSE(fd); } if(!buffer) return false; @@ -901,25 +883,13 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) int buffer_len = 0; char *buffer = nullptr; { - struct stat fst; - int fd; -#if defined(_MSC_VER) && _MSC_VER >= 1400 - if (_sopen_s(&fd, fixPathForFile(file->file, true).local().toLocal8Bit().constData(), - _O_RDONLY, _SH_DENYNO, _S_IREAD) != 0) - fd = -1; -#else - fd = open(fixPathForFile(file->file, true).local().toLocal8Bit().constData(), O_RDONLY); -#endif - if (fd == -1 || fstat(fd, &fst) || S_ISDIR(fst.st_mode)) { - if (fd != -1) - QT_CLOSE(fd); + QFile f(fixPathForFile(file->file, true).local()); + if (!f.open(QIODevice::ReadOnly)) return false; //shouldn't happen - } - buffer = getBuffer(fst.st_size); - while (int have_read = QT_READ(fd, buffer + buffer_len, fst.st_size - buffer_len)) + const qint64 fs = f.size(); + buffer = getBuffer(fs); + while (int have_read = f.read(buffer + buffer_len, fs - buffer_len)) buffer_len += have_read; - - QT_CLOSE(fd); } debug_msg(2, "findMocs: %s", file->file.local().toLatin1().constData()); |