summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qstorageinfo_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qstorageinfo_unix.cpp')
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp124
1 files changed, 101 insertions, 23 deletions
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 2a83e87b0c..45b32830cd 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -1,40 +1,32 @@
/****************************************************************************
**
** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
+** $QT_BEGIN_LICENSE:LGPL21$
** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -63,6 +55,13 @@
#elif defined(Q_OS_SOLARIS)
# include <sys/mnttab.h>
# include <sys/statvfs.h>
+#elif defined(Q_OS_HAIKU)
+# include <Directory.h>
+# include <Path.h>
+# include <Volume.h>
+# include <VolumeRoster.h>
+# include <fs_info.h>
+# include <sys/statvfs.h>
#else
# include <sys/statvfs.h>
#endif
@@ -76,6 +75,9 @@
# if !defined(ST_RDONLY)
# define ST_RDONLY 1 // hack for missing define on Android
# endif
+#elif defined(Q_OS_HAIKU)
+# define QT_STATFSBUF struct statvfs
+# define QT_STATFS ::statvfs
#else
# if defined(QT_LARGEFILE_SUPPORT)
# define QT_STATFSBUF struct statvfs64
@@ -135,6 +137,12 @@ private:
FILE *fp;
mntent mnt;
QByteArray buffer;
+#elif defined(Q_OS_HAIKU)
+ BVolumeRoster m_volumeRoster;
+
+ QByteArray m_rootPath;
+ QByteArray m_fileSystemType;
+ QByteArray m_device;
#endif
};
@@ -309,6 +317,63 @@ inline QByteArray QStorageIterator::device() const
return QByteArray(mnt.mnt_fsname);
}
+#elif defined(Q_OS_HAIKU)
+inline QStorageIterator::QStorageIterator()
+{
+}
+
+inline QStorageIterator::~QStorageIterator()
+{
+}
+
+inline bool QStorageIterator::isValid() const
+{
+ return true;
+}
+
+inline bool QStorageIterator::next()
+{
+ BVolume volume;
+
+ if (m_volumeRoster.GetNextVolume(&volume) != B_OK)
+ return false;
+
+ BDirectory directory;
+ if (volume.GetRootDirectory(&directory) != B_OK)
+ return false;
+
+ const BPath path(&directory);
+
+ fs_info fsInfo;
+ memset(&fsInfo, 0, sizeof(fsInfo));
+
+ if (fs_stat_dev(volume.Device(), &fsInfo) != 0)
+ return false;
+
+ m_rootPath = path.Path();
+ m_fileSystemType = QByteArray(fsInfo.fsh_name);
+
+ const QByteArray deviceName(fsInfo.device_name);
+ m_device = (deviceName.isEmpty() ? QByteArray::number(qint32(volume.Device())) : deviceName);
+
+ return true;
+}
+
+inline QString QStorageIterator::rootPath() const
+{
+ return QFile::decodeName(m_rootPath);
+}
+
+inline QByteArray QStorageIterator::fileSystemType() const
+{
+ return m_fileSystemType;
+}
+
+inline QByteArray QStorageIterator::device() const
+{
+ return m_device;
+}
+
#else
inline QStorageIterator::QStorageIterator()
@@ -390,6 +455,19 @@ static inline QString retrieveLabel(const QByteArray &device)
if (fileInfo.isSymLink() && fileInfo.symLinkTarget().toLocal8Bit() == device)
return fileInfo.fileName();
}
+#elif defined Q_OS_HAIKU
+ fs_info fsInfo;
+ memset(&fsInfo, 0, sizeof(fsInfo));
+
+ int32 pos = 0;
+ dev_t dev;
+ while ((dev = next_dev(&pos)) >= 0) {
+ if (fs_stat_dev(dev, &fsInfo) != 0)
+ continue;
+
+ if (qstrcmp(fsInfo.device_name, device.constData()) == 0)
+ return QString::fromLocal8Bit(fsInfo.volume_name);
+ }
#else
Q_UNUSED(device);
#endif
@@ -403,11 +481,11 @@ void QStorageInfoPrivate::doStat()
if (rootPath.isEmpty())
return;
- retreiveVolumeInfo();
+ retrieveVolumeInfo();
name = retrieveLabel(device);
}
-void QStorageInfoPrivate::retreiveVolumeInfo()
+void QStorageInfoPrivate::retrieveVolumeInfo()
{
QT_STATFSBUF statfs_buf;
int result;