diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-10-30 14:17:32 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-10-31 08:59:52 +0100 |
commit | 5b20f58c19fb7473785452a11187321a579cc7c1 (patch) | |
tree | c37b7cff4c41a8038b3a73f102382b83f5329738 /src | |
parent | c3eb521a0f10112df6b61d2592351c4eef2e1f9b (diff) |
Unify QFSFileEngine implementations on Windows and Unix
The functions for standard file system operations simply delegate to
the static functions in QFileSystemEngine, which are then implemented
separately for each platform. There is no need for the wrappers in
QFSFileEngine to be separately implemented as well.
The only noticeable difference between Unix and Windows versions was
the clearing of the meta data in QFSFileEngine::remove, which was only
done on Unix. This is now also done on Windows.
As a fly-by fix, correct the (internal only) documentation about case
sensitivity.
Change-Id: I274b34d5407fdfff2e0a2157bb5220607740a92a
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfsfileengine.cpp | 116 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 77 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 70 |
3 files changed, 88 insertions, 175 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 0d73839f8d..3042eac2f0 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -911,14 +911,7 @@ bool QFSFileEngine::supportsExtension(Extension extension) const } /*! \fn bool QFSFileEngine::caseSensitive() const - Returns \c true for Windows, false for Unix. -*/ - -/*! \fn bool QFSFileEngine::copy(const QString ©Name) - - For Windows or Apple platforms, copy the file to file \a copyName. - - Not implemented for other Unix platforms. + Returns \c false for Windows, true for Unix. */ /*! \fn QString QFSFileEngine::currentPath(const QString &fileName) @@ -950,11 +943,34 @@ bool QFSFileEngine::supportsExtension(Extension extension) const \reimp */ -/*! \fn QString QFSFileEngine::homePath() +/*! Returns the home path of the current user. \sa rootPath() */ +QString QFSFileEngine::homePath() +{ + return QFileSystemEngine::homePath(); +} + +/*! + Returns the root path. + + \sa homePath() +*/ +QString QFSFileEngine::rootPath() +{ + return QFileSystemEngine::rootPath(); +} + +/*! + Returns the temporary path (i.e., a path in which it is safe + to store temporary files). +*/ +QString QFSFileEngine::tempPath() +{ + return QFileSystemEngine::tempPath(); +} /*! \fn bool QFSFileEngine::isRelativePath() const \reimp @@ -968,9 +984,6 @@ bool QFSFileEngine::supportsExtension(Extension extension) const true if successful; otherwise returns \c false. */ -/*! \fn bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const - \reimp -*/ /*! \fn uint QFSFileEngine::ownerId(QAbstractFileEngine::FileOwner own) const In Unix, if stat() is successful, the \c uid is returned if @@ -984,35 +997,87 @@ bool QFSFileEngine::supportsExtension(Extension extension) const \reimp */ -/*! \fn bool QFSFileEngine::remove() - \reimp +/*! + For Windows or Apple platforms, copy the file to file \a copyName. + + Not implemented for other Unix platforms. */ +bool QFSFileEngine::copy(const QString ©Name) +{ + Q_D(QFSFileEngine); + QSystemError error; + bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(copyName), error); + if (!ret) + setError(QFile::CopyError, error.toString()); + return ret; +} -/*! \fn bool QFSFileEngine::rename(const QString &newName) +/*! \reimp */ +bool QFSFileEngine::remove() +{ + Q_D(QFSFileEngine); + QSystemError error; + bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); + d->metaData.clear(); + if (!ret) + setError(QFile::RemoveError, error.toString()); + return ret; +} - -/*! \fn bool QFSFileEngine::renameOverwrite(const QString &newName) +/*! \reimp */ - -/*! \fn bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const +bool QFSFileEngine::rename(const QString &newName) +{ + Q_D(QFSFileEngine); + QSystemError error; + bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); + if (!ret) + setError(QFile::RenameError, error.toString()); + return ret; +} +/*! \reimp */ +bool QFSFileEngine::renameOverwrite(const QString &newName) +{ + Q_D(QFSFileEngine); + QSystemError error; + bool ret = QFileSystemEngine::renameOverwriteFile(d->fileEntry, QFileSystemEntry(newName), error); + if (!ret) + setError(QFile::RenameError, error.toString()); + return ret; +} -/*! \fn QString QFSFileEngine::rootPath() - Returns the root path. +/*! + \reimp +*/ +bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const +{ + return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories); +} - \sa homePath() +/*! + \reimp */ +bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const +{ + return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories); +} -/*! \fn bool QFSFileEngine::setCurrentPath(const QString &path) + +/*! Sets the current path (e.g., for QDir), to \a path. Returns \c true if the new path exists; otherwise this function does nothing, and returns \c false. \sa currentPath() */ +bool QFSFileEngine::setCurrentPath(const QString &path) +{ + return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path)); +} /*! \fn bool QFSFileEngine::setPermissions(uint perms) \reimp @@ -1022,11 +1087,6 @@ bool QFSFileEngine::supportsExtension(Extension extension) const \reimp */ -/*! \fn QString QFSFileEngine::tempPath() - Returns the temporary path (i.e., a path in which it is safe - to store temporary files). -*/ - /*! \fn QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFileEngine::FileFlags type) const \internal */ diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index d4983c72af..4610e9306c 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -304,54 +304,6 @@ bool QFSFileEnginePrivate::nativeIsSequential() const return isSequentialFdFh(); } -bool QFSFileEngine::remove() -{ - Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); - d->metaData.clear(); - if (!ret) { - setError(QFile::RemoveError, error.toString()); - } - return ret; -} - -bool QFSFileEngine::copy(const QString &newName) -{ - Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error); - if (!ret) { - setError(QFile::CopyError, error.toString()); - } - return ret; -} - -bool QFSFileEngine::renameOverwrite(const QString &newName) -{ - Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::renameOverwriteFile(d->fileEntry, QFileSystemEntry(newName), error); - - if (!ret) - setError(QFile::RenameError, error.toString()); - - return ret; -} - -bool QFSFileEngine::rename(const QString &newName) -{ - Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); - - if (!ret) { - setError(QFile::RenameError, error.toString()); - } - - return ret; -} - bool QFSFileEngine::link(const QString &newName) { Q_D(QFSFileEngine); @@ -368,45 +320,16 @@ qint64 QFSFileEnginePrivate::nativeSize() const return sizeFdFh(); } -bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const -{ - return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories); -} - -bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const -{ - return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories); -} - bool QFSFileEngine::caseSensitive() const { return true; } -bool QFSFileEngine::setCurrentPath(const QString &path) -{ - return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path)); -} - QString QFSFileEngine::currentPath(const QString &) { return QFileSystemEngine::currentPath().filePath(); } -QString QFSFileEngine::homePath() -{ - return QFileSystemEngine::homePath(); -} - -QString QFSFileEngine::rootPath() -{ - return QFileSystemEngine::rootPath(); -} - -QString QFSFileEngine::tempPath() -{ - return QFileSystemEngine::tempPath(); -} QFileInfoList QFSFileEngine::drives() { diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 19cc3e6402..5b868cc447 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -443,66 +443,11 @@ bool QFSFileEnginePrivate::nativeIsSequential() const #endif } -bool QFSFileEngine::remove() -{ - Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); - if (!ret) - setError(QFile::RemoveError, error.toString()); - return ret; -} - -bool QFSFileEngine::copy(const QString ©Name) -{ - Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(copyName), error); - if (!ret) - setError(QFile::CopyError, error.toString()); - return ret; -} - -bool QFSFileEngine::rename(const QString &newName) -{ - Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); - if (!ret) - setError(QFile::RenameError, error.toString()); - return ret; -} - -bool QFSFileEngine::renameOverwrite(const QString &newName) -{ - Q_D(QFSFileEngine); - QSystemError error; - bool ret = QFileSystemEngine::renameOverwriteFile(d->fileEntry, QFileSystemEntry(newName), error); - if (!ret) - setError(QFile::RenameError, error.toString()); - return ret; -} - -bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const -{ - return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories); -} - -bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const -{ - return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories); -} - bool QFSFileEngine::caseSensitive() const { return false; } -bool QFSFileEngine::setCurrentPath(const QString &path) -{ - return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path)); -} - QString QFSFileEngine::currentPath(const QString &fileName) { #if !defined(Q_OS_WINRT) @@ -530,21 +475,6 @@ QString QFSFileEngine::currentPath(const QString &fileName) #endif // Q_OS_WINRT } -QString QFSFileEngine::homePath() -{ - return QFileSystemEngine::homePath(); -} - -QString QFSFileEngine::rootPath() -{ - return QFileSystemEngine::rootPath(); -} - -QString QFSFileEngine::tempPath() -{ - return QFileSystemEngine::tempPath(); -} - #if !defined(Q_OS_WINRT) // cf QStorageInfo::isReady static inline bool isDriveReady(const wchar_t *path) |