diff options
Diffstat (limited to 'qmake/library/ioutils.cpp')
-rw-r--r-- | qmake/library/ioutils.cpp | 63 |
1 files changed, 12 insertions, 51 deletions
diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp index 719d3b514a..38bb246341 100644 --- a/qmake/library/ioutils.cpp +++ b/qmake/library/ioutils.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the qmake application of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "ioutils.h" @@ -33,7 +8,8 @@ #include <qregularexpression.h> #ifdef Q_OS_WIN -# include <windows.h> +# include <qt_windows.h> +# include <private/qsystemerror_p.h> #else # include <sys/types.h> # include <sys/stat.h> @@ -161,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; } @@ -176,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); @@ -204,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); @@ -220,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; @@ -237,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 @@ -280,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; @@ -290,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); |