コード例 #1
0
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;
}
コード例 #2
0
static bool isPseudoFs(const QStorageIterator &it)
{
    QString mountDir = it.rootPath();
    if (isParentOf(QLatin1String("/dev"), mountDir)
        || isParentOf(QLatin1String("/proc"), mountDir)
        || isParentOf(QLatin1String("/sys"), mountDir)
        || isParentOf(QLatin1String("/var/run"), mountDir)
        || isParentOf(QLatin1String("/var/lock"), mountDir)) {
        return true;
    }

    QByteArray type = it.fileSystemType();
    if (type == "tmpfs")
        return false;
#if defined(Q_OS_LINUX)
    if (type == "rootfs" || type == "rpc_pipefs")
        return true;
#endif

    if (!it.device().startsWith('/'))
        return true;

    return false;
}