Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsavefile.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:header-decls-only
4
5#ifndef QSAVEFILE_H
6#define QSAVEFILE_H
7
8#include <QtCore/qglobal.h>
9
10#if QT_CONFIG(temporaryfile)
11
12#include <QtCore/qfiledevice.h>
13#include <QtCore/qstring.h>
14
15#ifdef open
16#error qsavefile.h must be included before any header file that defines open
17#endif
18
19QT_BEGIN_NAMESPACE
20
21class QAbstractFileEngine;
22class QSaveFilePrivate;
23
24class Q_CORE_EXPORT QSaveFile : public QFileDevice
25{
26 Q_OBJECT
27 Q_DECLARE_PRIVATE(QSaveFile)
28
29public:
30#if QT_CORE_REMOVED_SINCE(6, 11)
31 explicit QSaveFile(const QString &name);
32#endif
33 explicit QSaveFile(QObject *parent = nullptr);
34 explicit QSaveFile(const QString &name, QObject *parent = nullptr);
35 ~QSaveFile();
36
37 QString fileName() const override;
38 void setFileName(const QString &name);
39
40 Permissions permissions() const override;
41 bool setPermissions(Permissions permissionSpec) override;
42
43 QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override;
44 bool commit();
45
46 void cancelWriting();
47
48 void setDirectWriteFallback(bool enabled);
49 bool directWriteFallback() const;
50
51#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
52 Q_WEAK_OVERLOAD QSaveFile(const std::filesystem::path &path, QObject *parent = nullptr)
53 : QSaveFile(QtPrivate::fromFilesystemPath(path), parent)
54 {
55 }
56
57 std::filesystem::path filesystemFileName() const
58 { return QtPrivate::toFilesystemPath(fileName()); }
59 Q_WEAK_OVERLOAD void setFileName(const std::filesystem::path &name)
60 {
61 setFileName(QtPrivate::fromFilesystemPath(name));
62 }
63#endif // QT_CONFIG(cxx17_filesystem)
64
65protected:
66 qint64 writeData(const char *data, qint64 len) override;
67
68private:
69 void close() override;
70#if !QT_CONFIG(translation)
71 static QString tr(const char *string) { return QString::fromLatin1(string); }
72#endif
73
74private:
75 Q_DISABLE_COPY(QSaveFile)
76 friend class QFilePrivate;
77};
78
79QT_END_NAMESPACE
80
81#endif // QT_CONFIG(temporaryfile)
82
83#endif // QSAVEFILE_H
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582
static Q_DECL_COLD_FUNCTION bool file_already_open(QFile &file, const char *where=nullptr)
Definition qfile.cpp:33
#define QFILEINFO_MAYBE_EXPLICIT
Definition qfileinfo.h:34
QList< QFileInfo > QFileInfoList
Definition qfileinfo.h:192