rbutilqt: Simplify Utils::filesystemType() using QStorageInfo

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Tue, 7 Jul 2026 22:48:41 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit d06fa104851af6260d83fe711af5187fc8be4a3f
Author: Vencislav Atanasov <[email protected]>
Date:   Tue Jul 7 23:38:00 2026 +0300

    rbutilqt: Simplify Utils::filesystemType() using QStorageInfo
    
    Co-authored-by: Qwen3.7-Plus
    Change-Id: Ia3b51be02d6848199ab573399f566eed7a2df085

diff --git a/utils/rbutilqt/base/utils.cpp b/utils/rbutilqt/base/utils.cpp
index 1174e8e63a..ec83a4a043 100644
--- a/utils/rbutilqt/base/utils.cpp
+++ b/utils/rbutilqt/base/utils.cpp
@@ -135,45 +135,12 @@ QString Utils::resolvePathCase(QString path)
 
 QString Utils::filesystemType(QString path)
 {
-#if defined(Q_OS_LINUX)
-    FILE *mn = setmntent("/etc/mtab", "r");
-    if(!mn)
-        return QString("");
-
-    struct mntent *ent;
-    while((ent = getmntent(mn))) {
-        if(QString(ent->mnt_dir) == path) {
-            endmntent(mn);
-            LOG_INFO() << "device type is" << ent->mnt_type;
-            return QString(ent->mnt_type);
-        }
-    }
-    endmntent(mn);
-#endif
-
-#if defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD)
-    int num;
-    struct statfs *mntinf;
-
-    num = getmntinfo(&mntinf, MNT_WAIT);
-    while(num--) {
-        if(QString(mntinf->f_mntonname) == path) {
-            LOG_INFO() << "device type is" << mntinf->f_fstypename;
-            return QString(mntinf->f_fstypename);
-        }
-        mntinf++;
-    }
-#endif
-
-#if defined(Q_OS_WIN32)
-    wchar_t t[64];
-    memset(t, 0, 32);
-    if(GetVolumeInformationW((LPCWSTR)path.utf16(),
-                             NULL, 0, NULL, NULL, NULL, t, 64)) {
-        LOG_INFO() << "device type is" << t;
-        return QString::fromWCharArray(t);
+    QStorageInfo storage(path);
+    if (storage.isValid()) {
+        QString fsType = QString::fromLocal8Bit(storage.fileSystemType());
+        LOG_INFO() << "device type is" << fsType;
+        return fsType;
     }
-#endif
     return QString("-");
 }
 
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs