From 7a4f951bc36b789a5da2e2d22587fd8fadc4d029 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 9 Aug 2020 05:48:55 +0300 Subject: [PATCH] remove redundant QSystemError class Signed-off-by: Ivailo Monev --- src/core/CMakeLists.txt | 2 - src/core/io/qfilesystemengine_p.h | 11 ++--- src/core/io/qfilesystemengine_unix.cpp | 28 +++++------ src/core/io/qfsfileengine_unix.cpp | 30 ++++++------ src/core/io/qtemporaryfile.cpp | 1 - src/core/kernel/qsystemerror.cpp | 49 ------------------- src/core/kernel/qsystemerror_p.h | 88 ---------------------------------- src/tools/moc/CMakeLists.txt | 1 - 8 files changed, 34 insertions(+), 176 deletions(-) delete mode 100644 src/core/kernel/qsystemerror.cpp delete mode 100644 src/core/kernel/qsystemerror_p.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ef22e1973..c9ffd0f25 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -229,7 +229,6 @@ set(CORE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsystemsemaphore.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsystemsemaphore_p.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qmath.h - ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsystemerror_p.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qcore_unix_p.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qeventdispatcher_unix_p.h ${CMAKE_CURRENT_SOURCE_DIR}/plugin/qfactoryinterface.h @@ -375,7 +374,6 @@ set(CORE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsharedmemory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsystemsemaphore.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qpointer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsystemerror.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qcore_unix.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsharedmemory_unix.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsystemsemaphore_unix.cpp diff --git a/src/core/io/qfilesystemengine_p.h b/src/core/io/qfilesystemengine_p.h index 7c89c586b..cd1f1c3f7 100644 --- a/src/core/io/qfilesystemengine_p.h +++ b/src/core/io/qfilesystemengine_p.h @@ -48,7 +48,6 @@ #include "qfile.h" #include "qfilesystementry_p.h" #include "qfilesystemmetadata_p.h" -#include "qsystemerror_p.h" QT_BEGIN_NAMESPACE @@ -76,13 +75,13 @@ public: static bool createDirectory(const QFileSystemEntry &entry, bool createParents); static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents); - static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error); + static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, int *error); - static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error); - static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error); - static bool removeFile(const QFileSystemEntry &entry, QSystemError &error); + static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, int *error); + static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, int *error); + static bool removeFile(const QFileSystemEntry &entry, int *error); - static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error); + static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, int *error); static bool setCurrentPath(const QFileSystemEntry &entry); static QFileSystemEntry currentPath(); diff --git a/src/core/io/qfilesystemengine_unix.cpp b/src/core/io/qfilesystemengine_unix.cpp index c9ece5657..694d2e70e 100644 --- a/src/core/io/qfilesystemengine_unix.cpp +++ b/src/core/io/qfilesystemengine_unix.cpp @@ -322,16 +322,16 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } //static -bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, int *error) { if (::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0) return true; - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; return false; } //static -bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, int *error) { QT_STATBUF st; if (QT_STAT(source.nativeFilePath().constData(), &st) == 0) { @@ -341,13 +341,13 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst const int sourcefd = QT_OPEN(source.nativeFilePath().constData(), O_RDONLY); if (sourcefd == -1) { - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; return false; } const int targetfd = QT_CREAT(target.nativeFilePath().constData(), st.st_mode); if (targetfd == -1) { - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; ::close(sourcefd); return false; } @@ -365,7 +365,7 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst ssize_t sendresult = QT_SENDFILE(targetfd, sourcefd, Q_NULLPTR, tocopy); while (sendresult != tocopy) { if (sendresult == -1) { - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; ::close(sourcefd); ::close(targetfd); return false; @@ -381,7 +381,7 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst while (QT_OFF_T(totalwrite) != tocopy) { const size_t readresult = QT_READ(sourcefd, copybuffer, sizeof(copybuffer)); if (readresult == -1) { - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; ::close(sourcefd); ::close(targetfd); return false; @@ -389,7 +389,7 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst const size_t writeresult = QT_WRITE(targetfd, copybuffer, readresult); if (writeresult != readresult) { - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; ::close(sourcefd); ::close(targetfd); return false; @@ -405,26 +405,26 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst } //static -bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, int *error) { if (::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0) return true; - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; return false; } //static -bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error) +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, int *error) { if (unlink(entry.nativeFilePath().constData()) == 0) return true; - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; return false; } //static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error) +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, int *error) { mode_t mode = 0; if (permissions & QFile::ReadOwner) @@ -454,7 +454,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per if (::chmod(entry.nativeFilePath().constData(), mode) == 0) return true; - error = QSystemError(errno, QSystemError::StandardLibraryError); + *error = errno; return false; } diff --git a/src/core/io/qfsfileengine_unix.cpp b/src/core/io/qfsfileengine_unix.cpp index 3f2d77650..e61325010 100644 --- a/src/core/io/qfsfileengine_unix.cpp +++ b/src/core/io/qfsfileengine_unix.cpp @@ -300,11 +300,11 @@ int QFSFileEnginePrivate::nativeHandle() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); + int error; + bool ret = QFileSystemEngine::removeFile(d->fileEntry, &error); d->metaData.clear(); if (!ret) { - setError(QFile::RemoveError, error.toString()); + setError(QFile::RemoveError, qt_error_string(error)); } return ret; } @@ -312,10 +312,10 @@ bool QFSFileEngine::remove() bool QFSFileEngine::copy(const QString &newName) { Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error); + int error; + bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), &error); if (!ret) { - setError(QFile::CopyError, error.toString()); + setError(QFile::CopyError, qt_error_string(error)); } return ret; } @@ -323,11 +323,11 @@ bool QFSFileEngine::copy(const QString &newName) bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); + int error; + bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), &error); if (!ret) { - setError(QFile::RenameError, error.toString()); + setError(QFile::RenameError, qt_error_string(error)); } return ret; @@ -336,10 +336,10 @@ bool QFSFileEngine::rename(const QString &newName) bool QFSFileEngine::link(const QString &newName) { Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), error); + int error; + bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), &error); if (!ret) { - setError(QFile::RenameError, error.toString()); + setError(QFile::RenameError, qt_error_string(error)); } return ret; } @@ -531,9 +531,9 @@ QString QFSFileEngine::owner(FileOwner own) const bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); - QSystemError error; - if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error)) { - setError(QFile::PermissionsError, error.toString()); + int error; + if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), &error)) { + setError(QFile::PermissionsError, qt_error_string(error)); return false; } return true; diff --git a/src/core/io/qtemporaryfile.cpp b/src/core/io/qtemporaryfile.cpp index 637677cd1..d210a4762 100644 --- a/src/core/io/qtemporaryfile.cpp +++ b/src/core/io/qtemporaryfile.cpp @@ -38,7 +38,6 @@ #include "qplatformdefs.h" #include "qfile_p.h" #include "qfsfileengine_p.h" -#include "qsystemerror_p.h" #include "qfilesystemengine_p.h" #include "qcore_unix_p.h" // overrides QT_OPEN diff --git a/src/core/kernel/qsystemerror.cpp b/src/core/kernel/qsystemerror.cpp deleted file mode 100644 index ca5ead677..000000000 --- a/src/core/kernel/qsystemerror.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016-2020 Ivailo Monev -** -** This file is part of the QtCore module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsystemerror_p.h" - -QT_BEGIN_NAMESPACE - -QString QSystemError::toString() -{ - if (Q_LIKELY(errorScope == QSystemError::StandardLibraryError)) { - return qt_error_string(errorCode); - } - - qWarning("invalid error scope"); - return QLatin1String("No error"); -} - -QT_END_NAMESPACE - diff --git a/src/core/kernel/qsystemerror_p.h b/src/core/kernel/qsystemerror_p.h deleted file mode 100644 index 4714db73d..000000000 --- a/src/core/kernel/qsystemerror_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016-2020 Ivailo Monev -** -** This file is part of the QtCore module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSYSTEMERROR_P_H -#define QSYSTEMERROR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Katie API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qstring.h" - -QT_BEGIN_NAMESPACE - -class Q_CORE_EXPORT QSystemError -{ -public: - enum ErrorScope { - NoError, - StandardLibraryError - }; - - inline QSystemError(int error, ErrorScope scope); - inline QSystemError(); - - QString toString(); - inline ErrorScope scope() { return errorScope; } - inline int error() { return errorCode; } - -private: - //data members - int errorCode; - ErrorScope errorScope; -}; - -QSystemError::QSystemError(int error, QSystemError::ErrorScope scope) - : errorCode(error), errorScope(scope) -{ - -} - -QSystemError::QSystemError() - : errorCode(0), errorScope(NoError) -{ - -} - - -QT_END_NAMESPACE - -#endif // QSYSTEMERROR_P_H diff --git a/src/tools/moc/CMakeLists.txt b/src/tools/moc/CMakeLists.txt index b93daa459..1283429e8 100644 --- a/src/tools/moc/CMakeLists.txt +++ b/src/tools/moc/CMakeLists.txt @@ -64,7 +64,6 @@ set(BOOTSTRAP_SOURCES ${CMAKE_SOURCE_DIR}/src/core/io/qfilesystemiterator_unix.cpp ${CMAKE_SOURCE_DIR}/src/core/io/qfsfileengine_unix.cpp ${CMAKE_SOURCE_DIR}/src/core/kernel/qmetatype.cpp - ${CMAKE_SOURCE_DIR}/src/core/kernel/qsystemerror.cpp ${CMAKE_SOURCE_DIR}/src/core/tools/qbytearray.cpp ${CMAKE_SOURCE_DIR}/src/core/tools/qbytearraymatcher.cpp ${CMAKE_SOURCE_DIR}/src/core/tools/qchar.cpp -- 2.11.0