8#include <QtCore/qglobal.h>
10#if QT_CONFIG(temporaryfile)
12#include <QtCore/qfiledevice.h>
13#include <QtCore/qstring.h>
16#error qsavefile.h must be included before any header file that defines open
21class QAbstractFileEngine;
22class QSaveFilePrivate;
24class Q_CORE_EXPORT QSaveFile :
public QFileDevice
27 Q_DECLARE_PRIVATE(QSaveFile)
30#if QT_CORE_REMOVED_SINCE(6
, 11
)
31 explicit QSaveFile(
const QString &name);
33 explicit QSaveFile(QObject *parent =
nullptr);
34 explicit QSaveFile(
const QString &name, QObject *parent =
nullptr);
37 QString fileName()
const override;
38 void setFileName(
const QString &name);
41 Permissions permissions()
const override;
42 bool setPermissions(Permissions permissionSpec) override;
45 QFILE_MAYBE_NODISCARD
bool open(OpenMode flags) override;
50 void setDirectWriteFallback(
bool enabled);
51 bool directWriteFallback()
const;
53#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
54 Q_WEAK_OVERLOAD QSaveFile(
const std::filesystem::path &path, QObject *parent =
nullptr)
55 : QSaveFile(QtPrivate::fromFilesystemPath(path), parent)
59 std::filesystem::path filesystemFileName()
const
60 {
return QtPrivate::toFilesystemPath(fileName()); }
61 Q_WEAK_OVERLOAD
void setFileName(
const std::filesystem::path &name)
63 setFileName(QtPrivate::fromFilesystemPath(name));
68 qint64 writeData(
const char *data, qint64 len) override;
71 void close() override;
72#if !QT_CONFIG(translation)
73 static QString tr(
const char *string) {
return QString::fromLatin1(string); }
77 Q_DISABLE_COPY(QSaveFile)
78 friend class QFilePrivate;
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