diff options
Diffstat (limited to 'src/corelib/io/qtemporaryfile.h')
-rw-r--r-- | src/corelib/io/qtemporaryfile.h | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/corelib/io/qtemporaryfile.h b/src/corelib/io/qtemporaryfile.h index e1058e566c..9a4476f9d2 100644 --- a/src/corelib/io/qtemporaryfile.h +++ b/src/corelib/io/qtemporaryfile.h @@ -14,7 +14,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_TEMPORARYFILE +#if QT_CONFIG(temporaryfile) class QTemporaryFilePrivate; class QLockFilePrivate; @@ -32,26 +32,59 @@ public: #ifndef QT_NO_QOBJECT explicit QTemporaryFile(QObject *parent); QTemporaryFile(const QString &templateName, QObject *parent); -#endif + +# if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC) + Q_WEAK_OVERLOAD + explicit QTemporaryFile(const std::filesystem::path &templateName, QObject *parent = nullptr) + : QTemporaryFile(QtPrivate::fromFilesystemPath(templateName), parent) + { + } +# endif // QT_CONFIG(cxx17_filesystem) +#endif // !QT_NO_QOBJECT + ~QTemporaryFile(); bool autoRemove() const; void setAutoRemove(bool b); // ### Hides open(flags) - bool open() { return open(QIODevice::ReadWrite); } + QFILE_MAYBE_NODISCARD bool open() { return open(QIODevice::ReadWrite); } QString fileName() const override; QString fileTemplate() const; void setFileTemplate(const QString &name); +#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC) + Q_WEAK_OVERLOAD + void setFileTemplate(const std::filesystem::path &name) + { + return setFileTemplate(QtPrivate::fromFilesystemPath(name)); + } +#endif // QT_CONFIG(cxx17_filesystem) // Hides QFile::rename bool rename(const QString &newName); +#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC) + Q_WEAK_OVERLOAD + bool rename(const std::filesystem::path &newName) + { + return rename(QtPrivate::fromFilesystemPath(newName)); + } +#endif // QT_CONFIG(cxx17_filesystem) + inline static QTemporaryFile *createNativeFile(const QString &fileName) { QFile file(fileName); return createNativeFile(file); } static QTemporaryFile *createNativeFile(QFile &file); +#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC) + Q_WEAK_OVERLOAD + static QTemporaryFile *createNativeFile(const std::filesystem::path &fileName) + { + QFile file(fileName); + return createNativeFile(file); + } +#endif // QT_CONFIG(cxx17_filesystem) + protected: bool open(OpenMode flags) override; @@ -61,7 +94,7 @@ private: Q_DISABLE_COPY(QTemporaryFile) }; -#endif // QT_NO_TEMPORARYFILE +#endif // QT_CONFIG(temporaryfile) QT_END_NAMESPACE |