Changeset 1047
- Timestamp:
- Sep 3, 2011, 8:07:07 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/io/qfsfileengine_iterator_os2.cpp
r848 r1047 71 71 public: 72 72 inline QFSFileEngineIteratorPlatformSpecificData() 73 : dir(0), dirEntry(0), done(false) 73 : dir(0), dirEntry(0), root(false), seenDot(false), seenDotDot(false) 74 , done(false) 74 75 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) 75 76 , mt_file(0) … … 79 80 DIR *dir; 80 81 dirent *dirEntry; 81 bool done; 82 bool root : 1; 83 bool seenDot : 1; 84 bool seenDotDot : 1; 85 bool done : 1; 82 86 83 87 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) … … 93 97 public: 94 98 inline QFSFileEngineIteratorPlatformSpecificData() 95 : done(false), hdir(HDIR_CREATE) 99 : root(false), seenDot(false), seenDotDot(false) 100 , done(false), hdir(HDIR_CREATE) 96 101 { 97 102 memset(&findBuf, 0, sizeof(findBuf)); 98 103 } 104 105 99 106 100 107 static QDateTime convertFileDateTime(FDATE fdate, FTIME ftime); … … 102 109 void resetFileInfo() { d_ptr->clear(); } 103 110 104 bool done; 111 bool root : 1; 112 bool seenDot : 1; 113 bool seenDotDot : 1; 114 bool done : 1; 105 115 HDIR hdir; 106 116 FILEFINDBUF3L findBuf; … … 120 130 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) 121 131 if (::readdir_r(platform->dir, platform->mt_file, &platform->dirEntry) != 0) 122 platform->done = true; 132 platform->dirEntry = 0; 133 // filter out "." and ".." from root to have consistent behavior across 134 // different IFSes (some report them, some don't). 135 while (platform->root && platform->dirEntry && 136 ((!platform->seenDot && 137 (platform->seenDot = qstrcmp(platform->dirEntry->d_name, ".")) == 0) || 138 (!platform->seenDotDot && 139 (platform->seenDotDot = qstrcmp(platform->dirEntry->d_name, "..")) == 0))) 140 if (::readdir_r(platform->dir, platform->mt_file, &platform->dirEntry) != 0) 141 platform->dirEntry = 0; 123 142 #else 124 143 // ### add local lock to prevent breaking reentrancy 125 144 platform->dirEntry = ::readdir(platform->dir); 145 146 147 148 149 150 151 152 126 153 #endif // _POSIX_THREAD_SAFE_FUNCTIONS 127 154 if (!platform->dirEntry) { … … 142 169 return; 143 170 } 171 172 173 144 174 145 175 // set QFileInfo from find buffer … … 200 230 path.append(QLatin1Char('/')); 201 231 APIRET arc = NO_ERROR; 202 if (path.size() >= 2 && path.at(0).isLetter() && path.at(1) == QLatin1Char(':')) { 232 if (path.length() >= 2 && path.at(0).isLetter() && path.at(1) == QLatin1Char(':')) { 233 that->platform->root = path.length() == 3 && (path.at(2) == QLatin1Char('/')); 203 234 // check that the drive is ready before trying to open it which reduces 204 235 // delays and noise for drives with no media inserted … … 219 250 DosClose(hdrv); 220 251 } 252 253 221 254 } 222 255 … … 244 277 FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED, 245 278 &that->platform->findBuf, sizeof(that->platform->findBuf), 246 &count, FIL_STANDARDL) != NO_ERROR) { 279 &count, FIL_STANDARDL) != NO_ERROR || 280 (platform->root && platform->filterOutDots() != NO_ERROR)) { 247 281 that->platform->done = true; 248 282 } else { … … 268 302 269 303 #ifdef QT_OS2_USE_DOSFINDFIRST 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 270 323 271 324 //static
Note:
See TracChangeset
for help on using the changeset viewer.