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

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