Opened 15 years ago

Closed 14 years ago

Last modified 14 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 14 years ago.
Diff for qfsfileengine_os2.cpp

Download all attachments as: .zip

Change History (8)

comment:1 by Dmitry A. Kuminov, 15 years ago

Milestone: Qt 4.6.2Qt 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 by rudi, 14 years ago

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 by rudi, 14 years ago

Oops, a typo:

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

should be:

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

by rudi, 14 years ago

Attachment: no_floppy_drives.zip added

Diff for qfsfileengine_os2.cpp

comment:4 by Dmitry A. Kuminov, 14 years ago

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 by rudi, 14 years ago

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 by Dmitry A. Kuminov, 14 years ago

Resolution: fixed
Status: newclosed

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 by Dmitry A. Kuminov, 14 years ago

Milestone: Qt EnhancedQt 4.6.3
Note: See TracTickets for help on using tickets.