Haiku: Implement QStorageInfo for Haiku

Use Haiku's BVolumeRoster API to provide information
about available mount points in QStorageInfo.

Change-Id: I058bbb5f3f33372edc55d3e51079d3e16815f29f
Reviewed-by: Augustin Cavalier <waddlesplash@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Tobias Koenig 2015-02-02 11:53:46 +00:00
parent dd4f59b227
commit e731a96ac1

View File

@ -54,6 +54,12 @@
# include <sys/statvfs.h>
#elif defined(Q_OS_SOLARIS)
# include <sys/mnttab.h>
#elif defined(Q_OS_HAIKU)
# include <Directory.h>
# include <Path.h>
# include <Volume.h>
# include <VolumeRoster.h>
# include <sys/statvfs.h>
#else
# include <sys/statvfs.h>
#endif
@ -129,6 +135,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
};
@ -303,6 +315,54 @@ 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);
m_rootPath = path.Path();
m_fileSystemType = QByteArray(); // no public API to access it
m_device = QByteArray::number(static_cast<qint32>(volume.Device()));
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()