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