Warning, file /include/QtCore/qtemporaryfile.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QTEMPORARYFILE_H
0005 #define QTEMPORARYFILE_H
0006
0007 #include <QtCore/qiodevice.h>
0008 #include <QtCore/qfile.h>
0009
0010 #ifdef open
0011 #error qtemporaryfile.h must be included before any header file that defines open
0012 #endif
0013
0014 QT_BEGIN_NAMESPACE
0015
0016
0017 #ifndef QT_NO_TEMPORARYFILE
0018
0019 class QTemporaryFilePrivate;
0020 class QLockFilePrivate;
0021
0022 class Q_CORE_EXPORT QTemporaryFile : public QFile
0023 {
0024 #ifndef QT_NO_QOBJECT
0025 Q_OBJECT
0026 #endif
0027 Q_DECLARE_PRIVATE(QTemporaryFile)
0028
0029 public:
0030 QTemporaryFile();
0031 explicit QTemporaryFile(const QString &templateName);
0032 #ifndef QT_NO_QOBJECT
0033 explicit QTemporaryFile(QObject *parent);
0034 QTemporaryFile(const QString &templateName, QObject *parent);
0035
0036 # if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
0037 Q_WEAK_OVERLOAD
0038 explicit QTemporaryFile(const std::filesystem::path &templateName, QObject *parent = nullptr)
0039 : QTemporaryFile(QtPrivate::fromFilesystemPath(templateName), parent)
0040 {
0041 }
0042 # endif
0043 #endif
0044
0045 ~QTemporaryFile();
0046
0047 bool autoRemove() const;
0048 void setAutoRemove(bool b);
0049
0050
0051 bool open() { return open(QIODevice::ReadWrite); }
0052
0053 QString fileName() const override;
0054 QString fileTemplate() const;
0055 void setFileTemplate(const QString &name);
0056 #if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
0057 Q_WEAK_OVERLOAD
0058 void setFileTemplate(const std::filesystem::path &name)
0059 {
0060 return setFileTemplate(QtPrivate::fromFilesystemPath(name));
0061 }
0062 #endif
0063
0064
0065 bool rename(const QString &newName);
0066
0067 #if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
0068 Q_WEAK_OVERLOAD
0069 bool rename(const std::filesystem::path &newName)
0070 {
0071 return rename(QtPrivate::fromFilesystemPath(newName));
0072 }
0073 #endif
0074
0075 inline static QTemporaryFile *createNativeFile(const QString &fileName)
0076 { QFile file(fileName); return createNativeFile(file); }
0077 static QTemporaryFile *createNativeFile(QFile &file);
0078
0079 #if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
0080 Q_WEAK_OVERLOAD
0081 static QTemporaryFile *createNativeFile(const std::filesystem::path &fileName)
0082 {
0083 QFile file(fileName);
0084 return createNativeFile(file);
0085 }
0086 #endif
0087
0088 protected:
0089 bool open(OpenMode flags) override;
0090
0091 private:
0092 friend class QFile;
0093 friend class QLockFilePrivate;
0094 Q_DISABLE_COPY(QTemporaryFile)
0095 };
0096
0097 #endif
0098
0099 QT_END_NAMESPACE
0100
0101 #endif