1// Copyright (C) 2016 The Qt Company Ltd.
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:default
4
5#ifndef QTEMPORARYDIR_H
6#define QTEMPORARYDIR_H
7
8#include <QtCore/qglobal.h>
9#include <QtCore/qdir.h>
10#include <QtCore/qscopedpointer.h>
11
12QT_BEGIN_NAMESPACE
13
14
15#if QT_CONFIG(temporaryfile)
16
17class QTemporaryDirPrivate;
18
19class Q_CORE_EXPORT QTemporaryDir
20{
21public:
22 QTemporaryDir();
23 explicit QTemporaryDir(const QString &templateName);
24 QTemporaryDir(QTemporaryDir &&other) noexcept
25 : d_ptr{std::exchange(obj&: other.d_ptr, new_val: nullptr)}
26 { }
27
28 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QTemporaryDir)
29
30 ~QTemporaryDir();
31
32 void swap(QTemporaryDir &other) noexcept
33 { qt_ptr_swap(lhs&: d_ptr, rhs&: other.d_ptr); }
34
35 bool isValid() const;
36 QString errorString() const;
37
38 bool autoRemove() const;
39 void setAutoRemove(bool b);
40 bool remove();
41
42 QString path() const;
43 QString filePath(const QString &fileName) const;
44
45private:
46 QTemporaryDirPrivate *d_ptr;
47
48 Q_DISABLE_COPY(QTemporaryDir)
49};
50
51inline void swap(QTemporaryDir &lhs, QTemporaryDir &rhs) noexcept
52{
53 lhs.swap(other&: rhs);
54}
55
56#endif // QT_CONFIG(temporaryfile)
57
58QT_END_NAMESPACE
59
60#endif // QTEMPORARYDIR_H
61

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