void QStorageInfoPrivate::initRootPath() { rootPath = QFileInfo(rootPath).canonicalFilePath(); if (rootPath.isEmpty()) return; QStorageIterator it; if (!it.isValid()) { rootPath = QStringLiteral("/"); return; } int maxLength = 0; const QString oldRootPath = rootPath; rootPath.clear(); while (it.next()) { const QString mountDir = it.rootPath(); const QByteArray fsName = it.fileSystemType(); if (isPseudoFs(mountDir, fsName)) continue; // we try to find most suitable entry if (oldRootPath.startsWith(mountDir) && maxLength < mountDir.length()) { maxLength = mountDir.length(); rootPath = mountDir; device = it.device(); fileSystemType = fsName; } } }
QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() { QStorageIterator it; if (!it.isValid()) return QList<QStorageInfo>() << root(); QList<QStorageInfo> volumes; while (it.next()) { if (isPseudoFs(it)) continue; const QString mountDir = it.rootPath(); volumes.append(QStorageInfo(mountDir)); } return volumes; }
QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() { QStorageIterator it; if (!it.isValid()) return QList<QStorageInfo>() << root(); QList<QStorageInfo> volumes; while (it.next()) { const QString mountDir = it.rootPath(); const QByteArray fsName = it.fileSystemType(); if (isPseudoFs(mountDir, fsName)) continue; volumes.append(QStorageInfo(mountDir)); } return volumes; }