Changeset 178 for trunk/src/corelib/io


Ignore:
Timestamp:
Sep 11, 2009, 2:30:36 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: Fixed: QDirIterator("X:") would iterate over the current directory instead of the root. This eventually fixes problem 1 from #59.

File:
1 edited

Legend:

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

    r21 r178  
    121121    if (!platform->done && !platform->dir) {
    122122        QFSFileEngineIterator *that = const_cast<QFSFileEngineIterator *>(this);
    123         if ((that->platform->dir = ::opendir(QFile::encodeName(path()).data())) == 0) {
     123        QString path = that->path();
     124        // ensure the directory ends with a slash, otherwise for paths like 'X:'
     125        // we'll get the current directory's listing instead of the expected root
     126        if (!path.endsWith(QLatin1Char('/')))
     127            path.append(QLatin1Char('/'));
     128        if ((that->platform->dir = ::opendir(QFile::encodeName(path).data())) == 0) {
    124129            that->platform->done = true;
    125130        } else {
    126131            // ### Race condition; we should use fpathconf and dirfd().
    127             long maxPathName = ::pathconf(QFile::encodeName(path()).data(), _PC_NAME_MAX);
     132            long maxPathName = ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);
    128133            if ((int) maxPathName == -1)
    129134                maxPathName = FILENAME_MAX;
Note: See TracChangeset for help on using the changeset viewer.