rbutilqt: Simplify Utils::filesystemName()
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Mon, 29 Jun 2026 20:12:54 -0400
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 45bd7c4400fa127e0c8e7d35b144ad7f144212dc Author: Vencislav Atanasov <[email protected]> Date: Sun Jun 28 23:51:17 2026 +0300 rbutilqt: Simplify Utils::filesystemName() Co-authored-by: ChatGPT (GPT-5.3 Mini) <[email protected]> Change-Id: Ib8851f27c473afa0d656ea3885e4d65342d10ab5 diff --git a/utils/rbutilqt/base/utils.cpp b/utils/rbutilqt/base/utils.cpp index ec860847d5..820eab04c5 100644 --- a/utils/rbutilqt/base/utils.cpp +++ b/utils/rbutilqt/base/utils.cpp @@ -29,6 +29,7 @@ #include <QtCore> #include <QDebug> +#include <QStorageInfo> #include <cstdlib> #include <stdio.h> @@ -177,67 +178,9 @@ QString Utils::filesystemType(QString path) } -QString Utils::filesystemName(QString path) +QString Utils::filesystemName(const QString &path) { - QString name; -#if defined(Q_OS_WIN32) - wchar_t volname[MAX_PATH+1]; - bool res = GetVolumeInformationW((LPTSTR)path.utf16(), volname, MAX_PATH+1, - NULL, NULL, NULL, NULL, 0); - if(res) { - name = QString::fromWCharArray(volname); - } -#endif -#if defined(Q_OS_MACOS) - // BSD label does not include folder. - QString bsd = Utils::resolveDevicename(path).remove("/dev/"); - if(bsd.isEmpty()) { - return name; - } - OSStatus result; - ItemCount index = 1; - - do { - FSVolumeRefNum volrefnum; - HFSUniStr255 volname; - - result = FSGetVolumeInfo(kFSInvalidVolumeRefNum, index, &volrefnum, - kFSVolInfoFSInfo, NULL, &volname, NULL); - - if(result == noErr) { - GetVolParmsInfoBuffer volparms; - /* PBHGetVolParmsSync() is not available for 64bit while - FSGetVolumeParms() is available in 10.5+. Thus we need to use - PBHGetVolParmsSync() for 10.4, and that also requires 10.4 to - always use 32bit. - Qt 4 supports 32bit on 10.6 Cocoa only. - */ -#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 - if(FSGetVolumeParms(volrefnum, &volparms, sizeof(volparms)) == noErr) -#else - HParamBlockRec hpb; - hpb.ioParam.ioNamePtr = NULL; - hpb.ioParam.ioVRefNum = volrefnum; - hpb.ioParam.ioBuffer = (Ptr)&volparms; - hpb.ioParam.ioReqCount = sizeof(volparms); - if(PBHGetVolParmsSync(&hpb) == noErr) -#endif - { - if(volparms.vMServerAdr == 0) { - if(bsd == (char*)volparms.vMDeviceID) { - name = QString::fromUtf16( - reinterpret_cast<const char16_t*>(volname.unicode), - static_cast<int>(volname.length) - ); - break; - } - } - } - } - index++; - } while(result == noErr); -#endif - + QString name = QStorageInfo(path).displayName(); LOG_INFO() << "Volume name of" << path << "is" << name; return name; } diff --git a/utils/rbutilqt/base/utils.h b/utils/rbutilqt/base/utils.h index c3c7cb949c..1b61759a6e 100644 --- a/utils/rbutilqt/base/utils.h +++ b/utils/rbutilqt/base/utils.h @@ -51,7 +51,7 @@ public: static QString checkEnvironment(bool permission); static int compareVersionStrings(QString s1, QString s2); static QString trimVersionString(QString s); - static QString filesystemName(QString path); + static QString filesystemName(const QString &path); static QStringList mountpoints(enum MountpointsFilter type = MountpointsAll); static QString resolveDevicename(QString path); static QString resolveMountPoint(QString device); -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs