Changeset 614


Ignore:
Timestamp:
Feb 27, 2010, 12:27:27 AM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: QFSFileEngineIterator: Check that the drive is ready before trying to open it which reduces delays and noise for drives with no media inserted [based on the patch by rudi].

File:
1 edited

Legend:

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

    r564 r614  
    4444#include "qplatformdefs.h"
    4545#include "qfsfileengine_iterator_p.h"
     46
     47#include <qt_os2.h>
    4648
    4749#include <QtCore/qvariant.h>
     
    126128        if (!path.endsWith(QLatin1Char('/')))
    127129            path.append(QLatin1Char('/'));
    128         if ((that->platform->dir = ::opendir(QFile::encodeName(path).data())) == 0) {
     130        // check that the drive is ready before trying to open it which reduces
     131        // delays and noise for drives with no media inserted
     132        BYTE drv[3] = { path.at(0).cell(), ':', '\0' };
     133        BYTE buf[sizeof(FSQBUFFER2) + (3 * CCHMAXPATH)] = {0};
     134        ULONG bufSize = sizeof(buf);
     135        PFSQBUFFER2 pfsq = (PFSQBUFFER2) buf;
     136        APIRET arc = DosQueryFSAttach(drv, 0, FSAIL_QUERYNAME, pfsq, &bufSize);
     137        if (arc != NO_ERROR) {
     138            that->platform->dir = 0;
     139            that->platform->done = true;
     140        } else if ((that->platform->dir = ::opendir(QFile::encodeName(path).data())) == 0) {
    129141            that->platform->done = true;
    130142        } else {
Note: See TracChangeset for help on using the changeset viewer.