// This gets the next header if one is found void ZipDirIteratorPrivate::advance() { if ( !nextHeader ) { currentHeader = NULL; return; } CentralDirFileHeader* header; while ( (header = zip.d_ptr->centralDir->getNextFile()) ) { if (!path.isEmpty() && !header->sFileName.startsWith( path, (options & AbZip::CaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive ) ) break; // reached the end of the 'path' we are searching for // Check our filters if (entryMatches( header->sFileName, header )) return; } // no more items to iterate, take final 'nextHeader' if ( nextHeader ) currentHeader = nextHeader; nextHeader = NULL; }
/*! \internal */ void QDirIteratorPrivate::advance() { if (engine) { while (!fileEngineIterators.isEmpty()) { // Find the next valid iterator that matches the filters. QAbstractFileEngineIterator *it; while (it = fileEngineIterators.top(), it->hasNext()) { it->next(); if (entryMatches(it->currentFileName(), it->currentFileInfo())) return; } fileEngineIterators.pop(); delete it; } } else { #ifndef QT_NO_FILESYSTEMITERATOR QFileSystemEntry nextEntry; QFileSystemMetaData nextMetaData; while (!nativeIterators.isEmpty()) { // Find the next valid iterator that matches the filters. QFileSystemIterator *it; while (it = nativeIterators.top(), it->advance(nextEntry, nextMetaData)) { QFileInfo info(new QFileInfoPrivate(nextEntry, nextMetaData)); if (entryMatches(nextEntry.fileName(), info)) return; } nativeIterators.pop(); delete it; } #endif } currentFileInfo = nextFileInfo; nextFileInfo = QFileInfo(); }
void ZipDirIteratorPrivate::findFirst() { CentralDirFileHeader* header = zip.d_ptr->centralDir->getFirstFile(); while ( header ) { if (path.isEmpty() || header->sFileName.startsWith( path, (options & AbZip::CaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive ) ) { // Check our filters if (entryMatches( header->sFileName, header )) { currentHeader = nextHeader; return; } } // Try next file header = zip.d_ptr->centralDir->getNextFile(); } }
static APIRET storeNextFileInfo( CryptedVolume * pVolume, SearchData * pSearchData, PGEALIST pgeas, char * * ppData, ULONG * pcbData, ULONG ulLevel, ULONG flFlags) { APIRET rc; IsoDirEntry * pEntry; while ((pEntry = pSearchData->pIsoNext)) { logMsg(L_DBG, "testing entry %ld, pEntry->flFlags=%x, flFlags=%x, name=%s", pSearchData->iNext, pEntry->flFlags, flFlags, (char *) pEntry->chrName); /* OS/2 file info relevant to file matching is stored in the directory (file name and hidden flag) and in the file's info sector (read-only, system, and archive flags). So we try to reject the file by first looking at pEntry (fast) and then at the corresponding file's info sector (slow). The last step also gives us all the necessary file info. */ /* Does the current directory entry match the search criteria? */ if (entryMatches(pSearchData, pEntry)) { /* We must read the file's info sector to see whether the other flags (directory, read-only, archived) match with the criteria, and to return info about the file. If the storage file no longer exists, however, we silently skip this entry. Such a condition can occur when the file was deleted after the directory contents had been read. (It can also indicate an inconsistency (directory referring to non-existing file) but this should be handled by chkdsk). */ if (fileMatches2(pSearchData, pEntry)) { /* Store the file information in the buffer. */ if (!(pSearchData->flAttr & FILE_NON83)) strupr((char *) pEntry->chrName); /* !!! codepage */ rc = storeFileInfo( pVolume, 0, pgeas, (char *) pEntry->chrName, pEntry->flFlags & CDF_HIDDEN, ppData, pcbData, ulLevel, flFlags, pSearchData->iNext,pEntry); if (rc) return rc; advanceSearch(pSearchData); logMsg(L_DBG, "Ok, leaving storeNextFileInfo()"); return NO_ERROR; }/* end of: if (fileMatches2(pSearchData, pEntry)) */ } advanceSearch(pSearchData); } return ERROR_NO_MORE_FILES; }