1// Copyright (C) 2012 David Faure <faure@kde.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSAVEFILE_H
5#define QSAVEFILE_H
6
7#include <QtCore/qglobal.h>
8
9#ifndef QT_NO_TEMPORARYFILE
10
11#include <QtCore/qfiledevice.h>
12#include <QtCore/qstring.h>
13
14#ifdef open
15#error qsavefile.h must be included before any header file that defines open
16#endif
17
18QT_BEGIN_NAMESPACE
19
20class QAbstractFileEngine;
21class QSaveFilePrivate;
22
23class Q_CORE_EXPORT QSaveFile : public QFileDevice
24{
25#ifndef QT_NO_QOBJECT
26 Q_OBJECT
27#endif
28 Q_DECLARE_PRIVATE(QSaveFile)
29
30public:
31
32 explicit QSaveFile(const QString &name);
33#ifndef QT_NO_QOBJECT
34 explicit QSaveFile(QObject *parent = nullptr);
35 explicit QSaveFile(const QString &name, QObject *parent);
36#endif
37 ~QSaveFile();
38
39 QString fileName() const override;
40 void setFileName(const QString &name);
41
42 bool open(OpenMode flags) override;
43 bool commit();
44
45 void cancelWriting();
46
47 void setDirectWriteFallback(bool enabled);
48 bool directWriteFallback() const;
49
50protected:
51 qint64 writeData(const char *data, qint64 len) override;
52
53private:
54 void close() override;
55#if !QT_CONFIG(translation)
56 static QString tr(const char *string) { return QString::fromLatin1(string); }
57#endif
58
59private:
60 Q_DISABLE_COPY(QSaveFile)
61};
62
63QT_END_NAMESPACE
64
65#endif // QT_NO_TEMPORARYFILE
66
67#endif // QSAVEFILE_H
68

source code of qtbase/src/corelib/io/qsavefile.h