diff options
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/base/autodetection.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/utils.cpp | 52 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/utils.h | 6 |
3 files changed, 48 insertions, 12 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp index 4144cca19d..fa2fe63cb8 100644 --- a/rbutil/rbutilqt/base/autodetection.cpp +++ b/rbutil/rbutilqt/base/autodetection.cpp | |||
@@ -42,7 +42,7 @@ bool Autodetection::detect() | |||
42 | detectUsb(); | 42 | detectUsb(); |
43 | 43 | ||
44 | // Try detection via rockbox.info / rbutil.log | 44 | // Try detection via rockbox.info / rbutil.log |
45 | QStringList mounts = Utils::mountpoints(); | 45 | QStringList mounts = Utils::mountpoints(Utils::MountpointsSupported); |
46 | qDebug() << "[Autodetect] paths to check:" << mounts; | 46 | qDebug() << "[Autodetect] paths to check:" << mounts; |
47 | 47 | ||
48 | for(int i=0; i< mounts.size();i++) | 48 | for(int i=0; i< mounts.size();i++) |
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp index 3a19397efb..92eacbe313 100644 --- a/rbutil/rbutilqt/base/utils.cpp +++ b/rbutil/rbutilqt/base/utils.cpp | |||
@@ -568,39 +568,71 @@ QString Utils::resolveMountPoint(QString device) | |||
568 | } | 568 | } |
569 | 569 | ||
570 | 570 | ||
571 | QStringList Utils::mountpoints() | 571 | QStringList Utils::mountpoints(enum MountpointsFilter type) |
572 | { | 572 | { |
573 | QStringList supported; | ||
573 | QStringList tempList; | 574 | QStringList tempList; |
574 | #if defined(Q_OS_WIN32) | 575 | #if defined(Q_OS_WIN32) |
576 | supported << "FAT32" << "FAT16" << "FAT12"; | ||
575 | QFileInfoList list = QDir::drives(); | 577 | QFileInfoList list = QDir::drives(); |
576 | for(int i=0; i<list.size();i++) | 578 | for(int i=0; i<list.size();i++) |
577 | { | 579 | { |
578 | tempList << list.at(i).absolutePath(); | 580 | wchar_t t[32]; |
579 | qDebug() << "[Utils] Mounted on" << list.at(i).absolutePath(); | 581 | memset(t, 0, 32); |
582 | if(GetVolumeInformationW((LPCWSTR)list.at(i).absolutePath().utf16(), | ||
583 | NULL, 0, NULL, NULL, NULL, t, 32) == 0) { | ||
584 | // on error empty retrieved type -- don't rely on | ||
585 | // GetVolumeInformation not changing it. | ||
586 | memset(t, 0, sizeof(t)); | ||
587 | } | ||
588 | |||
589 | QString fstype = QString::fromWCharArray(t); | ||
590 | if(type == MountpointsAll || supported.contains(fstype)) { | ||
591 | tempList << list.at(i).absolutePath(); | ||
592 | qDebug() << "[Utils] Added:" << list.at(i).absolutePath() | ||
593 | << "type" << fstype; | ||
594 | } | ||
595 | else { | ||
596 | qDebug() << "[Utils] Ignored:" << list.at(i).absolutePath() | ||
597 | << "type" << fstype; | ||
598 | } | ||
580 | } | 599 | } |
581 | 600 | ||
582 | #elif defined(Q_OS_MACX) || defined(Q_OS_OPENBSD) | 601 | #elif defined(Q_OS_MACX) || defined(Q_OS_OPENBSD) |
602 | supported << "vfat" << "msdos"; | ||
583 | int num; | 603 | int num; |
584 | struct statfs *mntinf; | 604 | struct statfs *mntinf; |
585 | 605 | ||
586 | num = getmntinfo(&mntinf, MNT_WAIT); | 606 | num = getmntinfo(&mntinf, MNT_WAIT); |
587 | while(num--) { | 607 | while(num--) { |
588 | tempList << QString(mntinf->f_mntonname); | 608 | if(type == MountpointsAll || supported.contains(mntinf->f_fstypename)) { |
589 | qDebug() << "[Utils] Mounted on" << mntinf->f_mntonname | 609 | tempList << QString(mntinf->f_mntonname); |
590 | << "is" << mntinf->f_mntfromname << "type" << mntinf->f_fstypename; | 610 | qDebug() << "[Utils] Added:" << mntinf->f_mntonname |
611 | << "is" << mntinf->f_mntfromname << "type" << mntinf->f_fstypename; | ||
612 | } | ||
613 | else { | ||
614 | qDebug() << "[Utils] Ignored:" << mntinf->f_mntonname | ||
615 | << "is" << mntinf->f_mntfromname << "type" << mntinf->f_fstypename; | ||
616 | } | ||
591 | mntinf++; | 617 | mntinf++; |
592 | } | 618 | } |
593 | #elif defined(Q_OS_LINUX) | 619 | #elif defined(Q_OS_LINUX) |
594 | 620 | supported << "vfat" << "msdos"; | |
595 | FILE *mn = setmntent("/etc/mtab", "r"); | 621 | FILE *mn = setmntent("/etc/mtab", "r"); |
596 | if(!mn) | 622 | if(!mn) |
597 | return QStringList(""); | 623 | return QStringList(""); |
598 | 624 | ||
599 | struct mntent *ent; | 625 | struct mntent *ent; |
600 | while((ent = getmntent(mn))) { | 626 | while((ent = getmntent(mn))) { |
601 | tempList << QString(ent->mnt_dir); | 627 | if(type == MountpointsAll || supported.contains(ent->mnt_type)) { |
602 | qDebug() << "[Utils] Mounted on" << ent->mnt_dir | 628 | tempList << QString(ent->mnt_dir); |
603 | << "is" << ent->mnt_fsname << "type" << ent->mnt_type; | 629 | qDebug() << "[Utils] Added:" << ent->mnt_dir |
630 | << "is" << ent->mnt_fsname << "type" << ent->mnt_type; | ||
631 | } | ||
632 | else { | ||
633 | qDebug() << "[Utils] Ignored:" << ent->mnt_dir | ||
634 | << "is" << ent->mnt_fsname << "type" << ent->mnt_type; | ||
635 | } | ||
604 | } | 636 | } |
605 | endmntent(mn); | 637 | endmntent(mn); |
606 | 638 | ||
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h index db52bfb4e9..9905341ad1 100644 --- a/rbutil/rbutilqt/base/utils.h +++ b/rbutil/rbutilqt/base/utils.h | |||
@@ -35,6 +35,10 @@ public: | |||
35 | FilesystemFree, | 35 | FilesystemFree, |
36 | FilesystemClusterSize, | 36 | FilesystemClusterSize, |
37 | }; | 37 | }; |
38 | enum MountpointsFilter { | ||
39 | MountpointsAll, | ||
40 | MountpointsSupported, | ||
41 | }; | ||
38 | 42 | ||
39 | static bool recursiveRmdir(const QString &dirName); | 43 | static bool recursiveRmdir(const QString &dirName); |
40 | static QString resolvePathCase(QString path); | 44 | static QString resolvePathCase(QString path); |
@@ -46,7 +50,7 @@ public: | |||
46 | static QString checkEnvironment(bool permission); | 50 | static QString checkEnvironment(bool permission); |
47 | static int compareVersionStrings(QString s1, QString s2); | 51 | static int compareVersionStrings(QString s1, QString s2); |
48 | static QString filesystemName(QString path); | 52 | static QString filesystemName(QString path); |
49 | static QStringList mountpoints(void); | 53 | static QStringList mountpoints(enum MountpointsFilter type = MountpointsAll); |
50 | static QString resolveDevicename(QString path); | 54 | static QString resolveDevicename(QString path); |
51 | static QString resolveMountPoint(QString device); | 55 | static QString resolveMountPoint(QString device); |
52 | static QStringList findRunningProcess(QStringList names); | 56 | static QStringList findRunningProcess(QStringList names); |