Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#144 closed enhancement (fixed)

Don't show floppy drives

Reported by: rudi Owned by:
Priority: major Milestone: Qt 4.6.3
Component: QtCore Version:
Severity: low Keywords:
Cc:

Description

Inspired by #137 I'm asking myself if it would be complicated to remove A: and B: drives completely from the file dialogs on systems that don't have legacy floppy drives (notebooks, multimedia PCs). This case is indicated by ERROR_BAD_UNIT returned from certain DosXXX calls and can be simulated by not loading IBMxFLPY.ADD.

Attachments (1)

no_floppy_drives.zip (834 bytes) - added by rudi 9 years ago.
Diff for qfsfileengine_os2.cpp

Download all attachments as: .zip

Change History (8)

comment:1 Changed 9 years ago by dmik

  • Milestone changed from Qt 4.6.2 to Qt Enhanced

Actually it was like that at some stage (QFileDialog doesn't show drives if QFileInfo("X:").exists() returns false for them). But then I changed it because it also affected CD-ROM drives and to match the system behavior (where A: and B: are always shown).

What you propose though sounds like a possible way to go (nobody uses A: and B: nowadays anyway). This needs some testing and not for the next milestone.

comment:2 Changed 9 years ago by rudi

I have experimented a bit with the following code in qfsfileengine_os2.h. It seems to do the job. Needs a #define INCL_DOSDEVIOCTL ...

QFileInfoList QFSFileEngine::drives()
{
    QFileInfoList ret;

    ULONG driveBits, dummy;
    DosQueryCurrentDisk(&dummy, &driveBits);
    driveBits &= 0x3ffffff;

    char driveName[4] = "A:/";

    while(driveBits) {
	// hide non-existent floppies
        if (driveName[0] < 'C') {
            BIOSPARAMETERBLOCK	bpb;
            UCHAR       	ioc[2] = { driveName[0] - 'A', 0 };
            if (DosDevIOCtl((HFILE)-1, IOCTL_DISK, DSK_GETDEVICEPARAMS,
                            ioc, 2, NULL, &bpb, sizeof(bpb), NULL) != 0) {
                driveBits &= ~1;
            }
        }
        if (driveBits & 1)
            ret.append(QString::fromLatin1(driveName));
        driveName[0]++;
        driveBits = driveBits >> 1;
    }

    return ret;
}

comment:3 Changed 9 years ago by rudi

Oops, a typo:

UCHAR       	ioc[2] = { driveName[0] - 'A', 0 };

should be:

UCHAR       	ioc[2] = { 0, driveName[0] - 'A' };

Changed 9 years ago by rudi

Diff for qfsfileengine_os2.cpp

comment:4 Changed 9 years ago by dmik

The CD-ROMs with no disk in will be also hidden, right? After some thinking and recalling, my main argument now is that if you insert a disk to such a hidden drive, the drive will not appear in the drive list on its own -- you have to re-open the file dialog. This will confuse the users a lot I'm afraid.

At some stage, I even implemented support for new drive letter detection and reporting in QFileSystemWatcher (which also worked for USB sticks) but it showed bad performance (because of the need to query A: and B: mostly) so I dropped this idea.

comment:5 Changed 9 years ago by rudi

I remember the things you tried with the file system watcher...

But what I'm talking about here is not a temporarily missing floppy. It's about computers, that don't have floppy disk drives at all. The reason why the code above might also hide CDROM drives (Did you try it ? I thought I had tested that...) is probably a stupid mistake on my side: When I created the ticket, I suggested to check for ERROR_BAD_UNIT. But the code doesn't do so...

comment:6 Changed 9 years ago by dmik

  • Resolution set to fixed
  • Status changed from new to closed

Right, it seems to properly detect the "no floppy drive" case: only if I disable floppy in BIOS, both A: and B: disappear from the drive list in file dialogs.

And no, CD-ROMs don't disappear. From the code, it's quite obvious that CD-ROM is not affected :) BTW, I tried to cause CD-ROM to occupy letter B: and failed: RESERVEDRIVELETTER=A: causes an error message at boot time about an invalid drive letter and for some reason WPS doesn't even start in this case (wait clock pointer forever). This looks like a total surprise for it.

Committed in r796. Thank you.

comment:7 Changed 9 years ago by dmik

  • Milestone changed from Qt Enhanced to Qt 4.6.3
Note: See TracTickets for help on using tickets.