summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorJiDe Zhang <zccrs@live.com>2021-07-10 09:57:22 +0800
committerMårten Nordheim <marten.nordheim@qt.io>2021-09-14 03:18:04 +0200
commit413098c3e38263741c1281a61156326457436744 (patch)
treeb3b33ac795ea6015a0e997b316ef9a86399a4f4e /src/corelib/io
parentec3260e5c7107490fd7c8e196fed82e6ca188dca (diff)
feat: add new interfaces for std::filesystem::path
Add for QFile::exists/symLinkTarget/remove/moveToTrash/ rename/link/copy Change-Id: I4cbb908e945f043b2a5278a6d8d5149b2f20e871 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfile.cpp40
-rw-r--r--src/corelib/io/qfile.h71
2 files changed, 108 insertions, 3 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index e031e9c091..471d73fcb6 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -1173,6 +1173,46 @@ qint64 QFile::size() const
\since 6.0
\overload
*/
+/*!
+ \fn bool exists(const std::filesystem::path &fileName)
+ \since 6.3
+ \overload
+*/
+/*!
+ \fn std::filesystem::path QFile::filesystemSymLinkTarget() const
+ \since 6.3
+ Returns symLinkTarget() as \c{std::filesystem::path}.
+*/
+/*!
+ \fn std::filesystem::path QFile::filesystemSymLinkTarget(const std::filesystem::path &fileName)
+ \since 6.3
+ Returns symLinkTarget() as \c{std::filesystem::path} of \a fileName.
+*/
+/*!
+ \fn bool remove(const std::filesystem::path &fileName)
+ \since 6.3
+ \overload
+*/
+/*!
+ \fn bool moveToTrash(const std::filesystem::path &fileName, QString *pathInTrash)
+ \since 6.3
+ \overload
+*/
+/*!
+ \fn bool rename(const std::filesystem::path &oldName, const std::filesystem::path &newName)
+ \since 6.3
+ \overload
+*/
+/*!
+ \fn bool link(const std::filesystem::path &fileName, const std::filesystem::path &newName);
+ \since 6.3
+ \overload
+*/
+/*!
+ \fn bool copy(const std::filesystem::path &fileName, const std::filesystem::path &newName);
+ \since 6.3
+ \overload
+*/
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h
index 2074bd1cc4..70b094d3a9 100644
--- a/src/corelib/io/qfile.h
+++ b/src/corelib/io/qfile.h
@@ -172,51 +172,116 @@ public:
bool exists() const;
static bool exists(const QString &fileName);
+#ifdef Q_CLANG_QDOC
+ static bool exists(const std::filesystem::path &fileName);
+#elif QT_CONFIG(cxx17_filesystem)
+ template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
+ static bool exists(const T &fileName)
+ {
+ return exists(QtPrivate::fromFilesystemPath(fileName));
+ }
+#endif // QT_CONFIG(cxx17_filesystem)
QString symLinkTarget() const;
static QString symLinkTarget(const QString &fileName);
+#ifdef Q_CLANG_QDOC
+ std::filesystem::path filesystemSymLinkTarget() const;
+ static std::filesystem::path filesystemSymLinkTarget(const std::filesystem::path &fileName);
+#elif QT_CONFIG(cxx17_filesystem)
+ std::filesystem::path filesystemSymLinkTarget() const
+ {
+ return QtPrivate::toFilesystemPath(symLinkTarget());
+ }
+ template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
+ static std::filesystem::path filesystemSymLinkTarget(const T &fileName)
+ {
+ return QtPrivate::toFilesystemPath(symLinkTarget(QtPrivate::fromFilesystemPath(fileName)));
+ }
+#endif // QT_CONFIG(cxx17_filesystem)
bool remove();
static bool remove(const QString &fileName);
+#ifdef Q_CLANG_QDOC
+ static bool remove(const std::filesystem::path &fileName);
+#elif QT_CONFIG(cxx17_filesystem)
+ template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
+ static bool remove(const T &fileName)
+ {
+ return remove(QtPrivate::fromFilesystemPath(fileName));
+ }
+#endif // QT_CONFIG(cxx17_filesystem)
bool moveToTrash();
static bool moveToTrash(const QString &fileName, QString *pathInTrash = nullptr);
+#ifdef Q_CLANG_QDOC
+ static bool moveToTrash(const std::filesystem::path &fileName, QString *pathInTrash = nullptr);
+#elif QT_CONFIG(cxx17_filesystem)
+ template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
+ static bool moveToTrash(const T &fileName, QString *pathInTrash = nullptr)
+ {
+ return moveToTrash(QtPrivate::fromFilesystemPath(fileName), pathInTrash);
+ }
+#endif // QT_CONFIG(cxx17_filesystem)
bool rename(const QString &newName);
+ static bool rename(const QString &oldName, const QString &newName);
#ifdef Q_CLANG_QDOC
bool rename(const std::filesystem::path &newName);
+ static bool rename(const std::filesystem::path &oldName,
+ const std::filesystem::path &newName);
#elif QT_CONFIG(cxx17_filesystem)
template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
bool rename(const T &newName)
{
return rename(QtPrivate::fromFilesystemPath(newName));
}
+ template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
+ static bool rename(const T &oldName, const T &newName)
+ {
+ return rename(QtPrivate::fromFilesystemPath(oldName),
+ QtPrivate::fromFilesystemPath(newName));
+ }
#endif // QT_CONFIG(cxx17_filesystem)
- static bool rename(const QString &oldName, const QString &newName);
bool link(const QString &newName);
+ static bool link(const QString &fileName, const QString &newName);
#ifdef Q_CLANG_QDOC
bool link(const std::filesystem::path &newName);
+ static bool link(const std::filesystem::path &fileName,
+ const std::filesystem::path &newName);
#elif QT_CONFIG(cxx17_filesystem)
template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
bool link(const T &newName)
{
return link(QtPrivate::fromFilesystemPath(newName));
}
+ template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
+ static bool link(const T &fileName, const T &newName)
+ {
+ return link(QtPrivate::fromFilesystemPath(fileName),
+ QtPrivate::fromFilesystemPath(newName));
+ }
#endif // QT_CONFIG(cxx17_filesystem)
- static bool link(const QString &oldname, const QString &newName);
bool copy(const QString &newName);
+ static bool copy(const QString &fileName, const QString &newName);
#ifdef Q_CLANG_QDOC
bool copy(const std::filesystem::path &newName);
+ static bool copy(const std::filesystem::path &fileName,
+ const std::filesystem::path &newName);
#elif QT_CONFIG(cxx17_filesystem)
template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
bool copy(const T &newName)
{
return copy(QtPrivate::fromFilesystemPath(newName));
}
+ template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
+ static bool copy(const T &fileName, const T &newName)
+ {
+ return copy(QtPrivate::fromFilesystemPath(fileName),
+ QtPrivate::fromFilesystemPath(newName));
+ }
#endif // QT_CONFIG(cxx17_filesystem)
- static bool copy(const QString &fileName, const QString &newName);
bool open(OpenMode flags) override;
bool open(FILE *f, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle);