1// Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com>
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 QSTORAGEINFO_H
5#define QSTORAGEINFO_H
6
7#include <QtCore/qbytearray.h>
8#include <QtCore/qdir.h>
9#include <QtCore/qlist.h>
10#include <QtCore/qmetatype.h>
11#include <QtCore/qstring.h>
12#include <QtCore/qshareddata.h>
13
14QT_BEGIN_NAMESPACE
15
16class QDebug;
17
18class QStorageInfoPrivate;
19class Q_CORE_EXPORT QStorageInfo
20{
21public:
22 QStorageInfo();
23 explicit QStorageInfo(const QString &path);
24 explicit QStorageInfo(const QDir &dir);
25 QStorageInfo(const QStorageInfo &other);
26 ~QStorageInfo();
27
28 QStorageInfo &operator=(const QStorageInfo &other);
29 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QStorageInfo)
30
31 inline void swap(QStorageInfo &other) noexcept
32 { d.swap(other&: other.d); }
33
34 void setPath(const QString &path);
35
36 QString rootPath() const;
37 QByteArray device() const;
38 QByteArray subvolume() const;
39 QByteArray fileSystemType() const;
40 QString name() const;
41 QString displayName() const;
42
43 qint64 bytesTotal() const;
44 qint64 bytesFree() const;
45 qint64 bytesAvailable() const;
46 int blockSize() const;
47
48 inline bool isRoot() const;
49 bool isReadOnly() const;
50 bool isReady() const;
51 bool isValid() const;
52
53 void refresh();
54
55 static QList<QStorageInfo> mountedVolumes();
56 static QStorageInfo root();
57
58private:
59 friend class QStorageInfoPrivate;
60 friend inline bool operator==(const QStorageInfo &first, const QStorageInfo &second)
61 {
62 if (first.d == second.d)
63 return true;
64 return first.device() == second.device() && first.rootPath() == second.rootPath();
65 }
66
67 friend inline bool operator!=(const QStorageInfo &first, const QStorageInfo &second)
68 {
69 return !(first == second);
70 }
71
72 friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QStorageInfo &);
73 QExplicitlySharedDataPointer<QStorageInfoPrivate> d;
74};
75
76inline bool QStorageInfo::isRoot() const
77{ return *this == QStorageInfo::root(); }
78
79Q_DECLARE_SHARED(QStorageInfo)
80
81#ifndef QT_NO_DEBUG_STREAM
82Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QStorageInfo &);
83#endif
84
85QT_END_NAMESPACE
86
87QT_DECL_METATYPE_EXTERN(QStorageInfo, Q_CORE_EXPORT)
88
89#endif // QSTORAGEINFO_H
90

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