Fix scan of floppy drive under win
This should fix scan of floppy drives and also detection of non removable drives
This commit is contained in:
@@ -361,12 +361,29 @@ bool writeEeprom(const QString &filename, ProgressWidget *progress)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined WIN32 || !defined __GNUC__
|
||||||
|
bool isRemovableMedia( QString vol )
|
||||||
|
{
|
||||||
|
char szDosDeviceName[MAX_PATH];
|
||||||
|
UINT DriveType = GetDriveType( vol.replace("/","\\").toLatin1() );
|
||||||
|
if ( DriveType != DRIVE_REMOVABLE )
|
||||||
|
return false;
|
||||||
|
QueryDosDevice( vol.replace("/","").toLatin1(), szDosDeviceName, MAX_PATH );
|
||||||
|
if ( strstr( szDosDeviceName,"\\Floppy") != NULL ) { // its a floppy
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QString findMassstoragePath(const QString &filename)
|
QString findMassstoragePath(const QString &filename)
|
||||||
{
|
{
|
||||||
QString temppath;
|
QString temppath;
|
||||||
QStringList drives;
|
QStringList drives;
|
||||||
QString eepromfile;
|
QString eepromfile;
|
||||||
QString fsname;
|
QString fsname;
|
||||||
|
static QStringList blacklist;
|
||||||
|
|
||||||
#if defined WIN32 || !defined __GNUC__
|
#if defined WIN32 || !defined __GNUC__
|
||||||
foreach(QFileInfo drive, QDir::drives()) {
|
foreach(QFileInfo drive, QDir::drives()) {
|
||||||
WCHAR szVolumeName[256] ;
|
WCHAR szVolumeName[256] ;
|
||||||
@@ -374,16 +391,22 @@ QString findMassstoragePath(const QString &filename)
|
|||||||
DWORD dwSerialNumber = 0;
|
DWORD dwSerialNumber = 0;
|
||||||
DWORD dwMaxFileNameLength=256;
|
DWORD dwMaxFileNameLength=256;
|
||||||
DWORD dwFileSystemFlags=0;
|
DWORD dwFileSystemFlags=0;
|
||||||
bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
|
if (!blacklist.contains(drive.absolutePath())) {
|
||||||
if (ret) {
|
if (!isRemovableMedia( drive.absolutePath() )) {
|
||||||
QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ;
|
blacklist.append(drive.absolutePath());
|
||||||
temppath = drive.absolutePath();
|
} else {
|
||||||
eepromfile = temppath;
|
bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
|
||||||
eepromfile.append("/" + filename);
|
if (ret) {
|
||||||
if (QFile::exists(eepromfile)) {
|
QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ;
|
||||||
return eepromfile;
|
temppath = drive.absolutePath();
|
||||||
|
eepromfile = temppath;
|
||||||
|
eepromfile.append("/" + filename);
|
||||||
|
if (QFile::exists(eepromfile)) {
|
||||||
|
return eepromfile;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct mount_entry *entry;
|
struct mount_entry *entry;
|
||||||
|
|||||||
Reference in New Issue
Block a user