mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
rbutilqt: Simplify Utils::filesystemType() using QStorageInfo
Co-authored-by: Qwen3.7-Plus Change-Id: Ia3b51be02d6848199ab573399f566eed7a2df085
This commit is contained in:
parent
f62e29f311
commit
d06fa10485
1 changed files with 5 additions and 38 deletions
|
|
@ -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);
|
||||
}
|
||||
QStorageInfo storage(path);
|
||||
if (storage.isValid()) {
|
||||
QString fsType = QString::fromLocal8Bit(storage.fileSystemType());
|
||||
LOG_INFO() << "device type is" << fsType;
|
||||
return fsType;
|
||||
}
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
return QString("-");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue