diff options
author | David Schulz <[email protected]> | 2021-06-11 14:33:58 +0200 |
---|---|---|
committer | David Schulz <[email protected]> | 2021-06-17 06:35:40 +0000 |
commit | 3b127c04e80eb8cdd2f6695d6212a927dfd5105b (patch) | |
tree | f2a4789389b76d999043cfe0ab0b08993a015954 | |
parent | 410b02f8c5b1631c376e269c670c559524b5eabb (diff) |
Utils: add rename function to fileutils
Change-Id: Iaf47744819c21013661e3bd0275a04c1d68e9023
Reviewed-by: hjk <[email protected]>
-rw-r--r-- | src/libs/utils/fileutils.cpp | 7 | ||||
-rw-r--r-- | src/libs/utils/fileutils.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 146b4133d2f..0b0672ccc25 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -485,6 +485,13 @@ FilePath FileUtils::homePath() return FilePath::fromString(QDir::cleanPath(QDir::homePath())); } +bool FileUtils::renameFile(const FilePath &srcFilePath, const FilePath &tgtFilePath) +{ + QTC_ASSERT(!srcFilePath.needsDevice(), return false); + QTC_ASSERT(srcFilePath.scheme() == tgtFilePath.scheme(), return false); + return QFile::rename(srcFilePath.path(), tgtFilePath.path()); +} + QByteArray FileReader::fetchQrc(const QString &fileName) { QTC_ASSERT(fileName.startsWith(':'), return QByteArray()); diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index 230558bc13b..616feb3eabc 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -248,6 +248,7 @@ public: static FilePath commonPath(const FilePath &oldCommonPath, const FilePath &fileName); static QByteArray fileId(const FilePath &fileName); static FilePath homePath(); + static bool renameFile(const FilePath &srcFilePath, const FilePath &tgtFilePath); }; template<typename T> |