diff options
Diffstat (limited to 'src/corelib/io/qstorageinfo.cpp')
-rw-r--r-- | src/corelib/io/qstorageinfo.cpp | 86 |
1 files changed, 32 insertions, 54 deletions
diff --git a/src/corelib/io/qstorageinfo.cpp b/src/corelib/io/qstorageinfo.cpp index e2c1f0232f..b7a17febaf 100644 --- a/src/corelib/io/qstorageinfo.cpp +++ b/src/corelib/io/qstorageinfo.cpp @@ -1,41 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2022 The Qt Company Ltd. +// Copyright (C) 2015 Ivan Komissarov <ABBAPOH@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qstorageinfo.h" #include "qstorageinfo_p.h" @@ -44,6 +9,8 @@ QT_BEGIN_NAMESPACE +QT_IMPL_METATYPE_EXTERN(QStorageInfo) + /*! \class QStorageInfo \inmodule QtCore @@ -53,6 +20,8 @@ QT_BEGIN_NAMESPACE \ingroup io \ingroup shared + \compares equality + Allows retrieving information about the volume's space, its mount point, label, and filesystem name. @@ -70,6 +39,11 @@ QT_BEGIN_NAMESPACE \snippet code/src_corelib_io_qstorageinfo.cpp 2 */ +QStorageInfo::QStorageInfo(QStorageInfoPrivate &dd) + : d(&dd) +{ +} + /*! Constructs an empty QStorageInfo object. @@ -274,9 +248,10 @@ QByteArray QStorageInfo::device() const Returns the subvolume name for this volume. Some filesystem types allow multiple subvolumes inside one device, which - may be mounted in different paths. If the subvolume could be detected, it - is returned here. The format of the subvolume name is specific to each - filesystem type. + may be mounted in different paths (e.g. 'bind' mounts on Unix, or Btrfs + filesystem subvolumes). If the subvolume could be detected, its name is + returned by this function. The format of the subvolume name is specific + to each filesystem type. If this volume was not mounted from a subvolume of a larger filesystem or if the subvolume could not be detected, this function returns an empty byte @@ -397,7 +372,7 @@ QList<QStorageInfo> QStorageInfo::mountedVolumes() return QStorageInfoPrivate::mountedVolumes(); } -Q_GLOBAL_STATIC_WITH_ARGS(QStorageInfo, getRoot, (QStorageInfoPrivate::root())) +Q_GLOBAL_STATIC(QStorageInfo, getRoot, QStorageInfoPrivate::root()) /*! Returns a QStorageInfo object that represents the system root volume. @@ -413,26 +388,29 @@ QStorageInfo QStorageInfo::root() } /*! - \fn inline bool operator==(const QStorageInfo &first, const QStorageInfo &second) + \fn bool QStorageInfo::operator==(const QStorageInfo &lhs, const QStorageInfo &rhs) - \relates QStorageInfo - - Returns true if the \a first QStorageInfo object refers to the same drive or volume - as the \a second; otherwise it returns false. + Returns \c true if the QStorageInfo object \a lhs refers to the same drive or + volume as the QStorageInfo object \a rhs; otherwise it returns \c false. Note that the result of comparing two invalid QStorageInfo objects is always positive. */ /*! - \fn inline bool operator!=(const QStorageInfo &first, const QStorageInfo &second) - - \relates QStorageInfo + \fn bool QStorageInfo::operator!=(const QStorageInfo &lhs, const QStorageInfo &rhs) - Returns true if the \a first QStorageInfo object refers to a different drive or - volume than the \a second; otherwise returns false. + Returns \c true if the QStorageInfo object \a lhs refers to a different drive or + volume than the QStorageInfo object \a rhs; otherwise returns \c false. */ +bool comparesEqual(const QStorageInfo &lhs, const QStorageInfo &rhs) +{ + if (lhs.d == rhs.d) + return true; + return lhs.device() == rhs.device() && lhs.rootPath() == rhs.rootPath(); +} + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, const QStorageInfo &s) { @@ -456,12 +434,12 @@ QDebug operator<<(QDebug debug, const QStorageInfo &s) debug << (d->ready ? " [ready]" : " [not ready]"); if (d->bytesTotal > 0) { debug << ", bytesTotal=" << d->bytesTotal << ", bytesFree=" << d->bytesFree - << ", bytesAvailable=" << d->bytesAvailable; + << ", bytesAvailable=" << d->bytesAvailable; } } else { debug << "invalid"; } - debug<< ')'; + debug << ')'; return debug; } #endif // !QT_NO_DEBUG_STREAM |