Changeset 375


Ignore:
Timestamp:
Dec 3, 2009, 9:41:12 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib/io: Fixed several QFSFileEngine bugs (#109):

  • RootFlag was not reported for drive root paths ("X:/" and "X:") which in particular caused letters of removable drives with no media inserted to be hidden in the file dialogs and other weird behavior such as empty nodes in the tree-like filesystem view.
  • Hidden files were not actually reported as hidden.
Location:
trunk/src/corelib/io
Files:
3 edited

Legend:

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

    r172 r375  
    106106    is_sequential = 0;
    107107    tried_stat = 0;
    108 #ifdef Q_OS_UNIX
     108#if
    109109    need_lstat = 1;
    110110    is_link = 0;
     111
     112
     113
    111114#endif
    112115    openMode = QIODevice::NotOpen;
  • trunk/src/corelib/io/qfsfileengine_os2.cpp

    r367 r375  
    166166}
    167167
     168
     169
     170
     171
     172
     173
     174
     175
    168176/*!
    169177    \internal
     
    617625{
    618626    if (tried_stat == 0) {
    619         QFSFileEnginePrivate *that = const_cast<QFSFileEnginePrivate*>(this);
    620627        if (fh && nativeFilePath.isEmpty()) {
    621628            // ### actually covers two cases: d->fh and when the file is not open
    622             that->could_stat = (QT_FSTAT(fileno(fh), &st) == 0);
     629            could_stat = (QT_FSTAT(fileno(fh), &st) == 0);
    623630        } else if (fd == -1) {
    624631            // ### actually covers two cases: d->fh and when the file is not open
    625             that->could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0);
     632            if (isDriveRootPath(filePath)) {
     633                // it's a root directory of the drive. Check that the drive is
     634                // ready: an attempt to stat() on a removable drive with no
     635                // media inserted will cause an unnecessary delay and noise.
     636                not_ready = 0;
     637                BYTE drv[3] = { filePath.at(0).cell(), ':', '\0' };
     638                BYTE buf[sizeof(FSQBUFFER2) + (3 * CCHMAXPATH)] = {0};
     639                ULONG bufSize = sizeof(buf);
     640                PFSQBUFFER2 pfsq = (PFSQBUFFER2) buf;
     641                APIRET arc = DosQueryFSAttach(drv, 0, FSAIL_QUERYNAME, pfsq,
     642                                              &bufSize);
     643                if (arc == ERROR_NOT_READY) {
     644                    // it must be a removable drive with no media in it
     645                    memset(&st, 0, sizeof(st));
     646                    st.st_mode = S_IFDIR | 0777;
     647                    not_ready = 1;
     648                    could_stat = true;
     649                } else if (arc != NO_ERROR) {
     650                    Q_ASSERT(arc == ERROR_INVALID_DRIVE);
     651                    could_stat = false;
     652                } else {
     653                    could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0);
     654                }
     655            } else {
     656                could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0);
     657            }
    626658        } else {
    627             that->could_stat = (QT_FSTAT(fd, &st) == 0);
    628         }
    629         that->tried_stat = 1;
     659            could_stat = (QT_FSTAT(fd, &st) == 0);
     660        }
     661tried_stat = 1;
    630662    }
    631663    return could_stat;
     
    700732        if (exists)
    701733            ret |= ExistsFlag;
    702         if (fileName(BaseName)[0] == QLatin1Char('.'))
     734        if ()
    703735            ret |= HiddenFlag;
    704         if (d->filePath == QLatin1String("/"))
     736        if ())
    705737            ret |= RootFlag;
    706738    }
     
    963995    Q_D(const QFSFileEngine);
    964996    QDateTime ret;
    965     if (d->doStat()) {
     997    if (d->doStat()) {
    966998        if (time == CreationTime)
    967999            ret.setTime_t(d->st.st_ctime ? d->st.st_ctime : d->st.st_mtime);
  • trunk/src/corelib/io/qfsfileengine_p.h

    r18 r375  
    143143    mutable uint is_link : 1;
    144144#endif
     145
     146
     147
    145148    bool doStat() const;
    146149    bool isSymlink() const;
Note: See TracChangeset for help on using the changeset viewer.