Changeset 796


Ignore:
Timestamp:
Oct 18, 2010, 7:09:36 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib/io: Don't report non-existent floppy drives in QDir::drives(). This makes letter A: and B: disappear from standard file dialogs in case if the computer doesn't have the floppy controller at all or it is disabled in BIOS [patch by rudi].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/io/qfsfileengine_os2.cpp

    r794 r796  
    6969#include <grp.h>
    7070
     71
    7172#include "qt_os2.h"
    7273
     
    590591    QFileInfoList ret;
    591592
    592         ULONG driveBits, dummy;
    593         DosQueryCurrentDisk(&dummy, &driveBits);
    594         driveBits &= 0x3ffffff;
    595 
    596         char driveName[4];
    597         qstrcpy(driveName, "A:/");
    598 
    599         while(driveBits) {
    600             if (driveBits & 1)
     593    ULONG driveBits, dummy;
     594    DosQueryCurrentDisk(&dummy, &driveBits);
     595    driveBits &= 0x3ffffff;
     596
     597    char driveName[4] = "A:/";
     598
     599    while (driveBits) {
     600        if (driveName[0] < 'C') {
     601            // hide non-existent floppies
     602            BIOSPARAMETERBLOCK  bpb;
     603            UCHAR               ioc[2] = { 0, driveName[0] - 'A' };
     604            if (DosDevIOCtl((HFILE)-1, IOCTL_DISK, DSK_GETDEVICEPARAMS,
     605                            ioc, 2, NULL, &bpb, sizeof(bpb), NULL) != 0) {
     606                driveBits &= ~1;
     607            }
     608        }
     609        if (driveBits & 1)
    601610            ret.append(QString::fromLatin1(driveName).toUpper());
    602             driveName[0]++;
    603             driveBits = driveBits >> 1;
    604         }
     611    driveName[0]++;
     612    driveBits = driveBits >> 1;
     613}
    605614
    606615    return ret;
Note: See TracChangeset for help on using the changeset viewer.