diff options
author | hjk <[email protected]> | 2021-06-28 13:57:10 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2021-06-28 13:03:32 +0000 |
commit | 54b40229879d72ecf02b53dd4c3634eb90ffdf0e (patch) | |
tree | a7a3803192aca0fd6c559a270d82dbf58e76f616 /src/libs | |
parent | 782779f8f4d1b572c87ee9d984ccd698aee1cdd5 (diff) |
Utils: Implement FilePath::rename()
And uses it in CMake's fileapi reader.
Change-Id: I9e719aa4b253eaca17c6b304eab5e7268fcfab29
Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 9 | ||||
-rw-r--r-- | src/libs/utils/fileutils.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 46395830f33..9311801e069 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -1415,6 +1415,15 @@ bool FilePath::copyFile(const FilePath &target) const return QFile::copy(path(), target.path()); } +bool FilePath::renameFile(const FilePath &target) const +{ + if (needsDevice()) { + QTC_ASSERT(s_deviceHooks.renameFile, return false); + return s_deviceHooks.renameFile(*this, target); + } + return QFile::rename(path(), target.path()); +} + QTextStream &operator<<(QTextStream &s, const FilePath &fn) { return s << fn.toString(); diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index b02b7f095f9..808f140ce58 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -79,6 +79,7 @@ public: std::function<bool(const FilePath &)> exists; std::function<bool(const FilePath &)> removeFile; std::function<bool(const FilePath &, const FilePath &)> copyFile; + std::function<bool(const FilePath &, const FilePath &)> renameFile; std::function<FilePath(const FilePath &)> searchInPath; std::function<QList<FilePath>(const FilePath &, const QStringList &, QDir::Filters)> dirEntries; std::function<QByteArray(const FilePath &, int)> fileContents; @@ -167,6 +168,7 @@ public: QFile::Permissions permissions() const; bool removeFile() const; bool copyFile(const FilePath &target) const; + bool renameFile(const FilePath &target) const; Qt::CaseSensitivity caseSensitivity() const; |