4#ifndef QTEMPORARYFILE_H
5#define QTEMPORARYFILE_H
7#include <QtCore/qiodevice.h>
8#include <QtCore/qfile.h>
11#error qtemporaryfile.h must be included before any header file that defines open
17#if QT_CONFIG(temporaryfile)
19class QTemporaryFilePrivate;
20class QLockFilePrivate;
22class Q_CORE_EXPORT QTemporaryFile :
public QFile
27 Q_DECLARE_PRIVATE(QTemporaryFile)
31 explicit QTemporaryFile(
const QString &templateName);
33 explicit QTemporaryFile(QObject *parent);
34 QTemporaryFile(
const QString &templateName, QObject *parent);
36# if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
38 explicit QTemporaryFile(
const std::filesystem::path &templateName, QObject *parent =
nullptr)
39 : QTemporaryFile(QtPrivate::fromFilesystemPath(templateName), parent)
47 bool autoRemove()
const;
48 void setAutoRemove(
bool b);
51 QFILE_MAYBE_NODISCARD
bool open() {
return open(QIODevice::ReadWrite); }
53 QString fileName()
const override;
54 QString fileTemplate()
const;
55 void setFileTemplate(
const QString &name);
56#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
58 void setFileTemplate(
const std::filesystem::path &name)
60 return setFileTemplate(QtPrivate::fromFilesystemPath(name));
65 bool rename(
const QString &newName);
67#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
69 bool rename(
const std::filesystem::path &newName)
71 return rename(QtPrivate::fromFilesystemPath(newName));
75 inline static QTemporaryFile *createNativeFile(
const QString &fileName)
76 { QFile file(fileName);
return createNativeFile(file); }
77 static QTemporaryFile *createNativeFile(QFile &file);
79#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
81 static QTemporaryFile *createNativeFile(
const std::filesystem::path &fileName)
84 return createNativeFile(file);
89 bool open(OpenMode flags) override;
93 friend class QLockFilePrivate;
94 Q_DISABLE_COPY(QTemporaryFile)
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
static Q_DECL_COLD_FUNCTION bool file_already_open(QFile &file, const char *where=nullptr)
#define QFILEINFO_MAYBE_EXPLICIT
QList< QFileInfo > QFileInfoList