From f7716a0899fba150fcde29f5b03da06dd284c6be Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Mon, 16 Feb 2015 15:00:53 +0000 Subject: [PATCH] Haiku: Extend QStorageInfo implementation Provide the file system type, the name (label) of the volume and the path to the associated device (if available). Change-Id: I7dd0d314d3f757e0f57c8f82beaf8ee21da86167 Reviewed-by: Augustin Cavalier Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 667301b516..7e23ac897d 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -59,6 +59,7 @@ # include # include # include +# include # include #else # include @@ -341,9 +342,18 @@ inline bool QStorageIterator::next() 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(); // no public API to access it - m_device = QByteArray::number(static_cast(volume.Device())); + m_fileSystemType = QByteArray(fsInfo.fsh_name); + + const QByteArray deviceName(fsInfo.device_name); + m_device = (deviceName.isEmpty() ? QByteArray::number(qint32(volume.Device())) : deviceName); return true; } @@ -444,6 +454,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