OSDN Git Service

remove redundant QSystemError class
authorIvailo Monev <xakepa10@gmail.com>
Sun, 9 Aug 2020 02:48:55 +0000 (05:48 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 9 Aug 2020 13:09:53 +0000 (16:09 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/CMakeLists.txt
src/core/io/qfilesystemengine_p.h
src/core/io/qfilesystemengine_unix.cpp
src/core/io/qfsfileengine_unix.cpp
src/core/io/qtemporaryfile.cpp
src/core/kernel/qsystemerror.cpp [deleted file]
src/core/kernel/qsystemerror_p.h [deleted file]
src/tools/moc/CMakeLists.txt

index ef22e19..c9ffd0f 100644 (file)
@@ -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
index 7c89c58..cd1f1c3 100644 (file)
@@ -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();
index c9ece56..694d2e7 100644 (file)
@@ -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;
 }
 
index 3f2d776..e613250 100644 (file)
@@ -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;
index 637677c..d210a47 100644 (file)
@@ -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 (file)
index ca5ead6..0000000
+++ /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 (file)
index 4714db7..0000000
+++ /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
index b93daa4..1283429 100644 (file)
@@ -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