diff options
Diffstat (limited to 'qmake/library/ioutils.cpp')
-rw-r--r-- | qmake/library/ioutils.cpp | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp index 5a5c455264..38bb246341 100644 --- a/qmake/library/ioutils.cpp +++ b/qmake/library/ioutils.cpp @@ -9,6 +9,7 @@ #ifdef Q_OS_WIN # include <qt_windows.h> +# include <private/qsystemerror_p.h> #else # include <sys/types.h> # include <sys/stat.h> @@ -136,7 +137,7 @@ bool isSpecialChar(ushort c, const uchar (&iqm)[16]) inline static bool hasSpecialChars(const QString &arg, const uchar (&iqm)[16]) { - for (int x = arg.length() - 1; x >= 0; --x) { + for (int x = arg.size() - 1; x >= 0; --x) { if (isSpecialChar(arg.unicode()[x].unicode(), iqm)) return true; } @@ -151,7 +152,7 @@ QString IoUtils::shellQuoteUnix(const QString &arg) 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78 }; // 0-32 \'"$`<>|;&(){}*?#!~[] - if (!arg.length()) + if (!arg.size()) return QString::fromLatin1("''"); QString ret(arg); @@ -179,7 +180,7 @@ QString IoUtils::shellQuoteWin(const QString &arg) 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10 }; // &()<>^| - if (!arg.length()) + if (!arg.size()) return QString::fromLatin1("\"\""); QString ret(arg); @@ -195,7 +196,7 @@ QString IoUtils::shellQuoteWin(const QString &arg) // to the called process verbatim. In the unquoted state, the circumflex escapes // meta chars (including itself and quotes), and is removed from the command. bool quoted = true; - for (int i = 0; i < ret.length(); i++) { + for (int i = 0; i < ret.size(); i++) { QChar c = ret.unicode()[i]; if (c.unicode() == '"') quoted = !quoted; @@ -212,23 +213,6 @@ QString IoUtils::shellQuoteWin(const QString &arg) #if defined(PROEVALUATOR_FULL) -# if defined(Q_OS_WIN) -static QString windowsErrorCode() -{ - wchar_t *string = nullptr; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR)&string, - 0, - NULL); - QString ret = QString::fromWCharArray(string); - LocalFree((HLOCAL)string); - return ret.trimmed(); -} -# endif - bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceFileName, QString *errorString) { # ifdef Q_OS_UNIX @@ -255,7 +239,8 @@ bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceF GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (rHand == INVALID_HANDLE_VALUE) { - *errorString = fL1S("Cannot open reference file %1: %2").arg(referenceFileName, windowsErrorCode()); + *errorString = fL1S("Cannot open reference file %1: %2") + .arg(referenceFileName, QSystemError::windowsString()); return false; } FILETIME ft; @@ -265,7 +250,8 @@ bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceF GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (wHand == INVALID_HANDLE_VALUE) { - *errorString = fL1S("Cannot open %1: %2").arg(targetFileName, windowsErrorCode()); + *errorString = fL1S("Cannot open %1: %2") + .arg(targetFileName, QSystemError::windowsString()); return false; } SetFileTime(wHand, NULL, NULL, &ft); |