MCPcopy Create free account
hub / github.com/KDE/kdiff3 / listDir

Method listDir

src/DefaultFileAccessJobHandler.cpp:374–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374bool DefaultFileAccessJobHandler::listDir(DirectoryList* pDirList, bool bRecursive, bool bFindHidden, const QString& filePattern,
375 const QString& fileAntiPattern, const QString& dirAntiPattern, bool bFollowDirLinks, IgnoreList& ignoreList)
376{
377 ProgressProxyExtender pp;
378 m_pDirList = pDirList;
379 m_pDirList->clear();
380 m_bFindHidden = bFindHidden;
381 m_bRecursive = bRecursive;
382 m_bFollowDirLinks = bFollowDirLinks; // Only relevant if bRecursive==true.
383 m_fileAntiPattern = fileAntiPattern;
384 m_filePattern = filePattern;
385 m_dirAntiPattern = dirAntiPattern;
386
387 if(ProgressProxy::wasCancelled())
388 return true; // Cancelled is not an error.
389
390 ProgressProxy::setInformation(i18nc("Status message", "Reading folder: %1", mFileAccess->absoluteFilePath()), 0, false);
391 qCInfo(kdiffFileAccess) << "Reading folder: " << mFileAccess->absoluteFilePath();
392
393 if(mFileAccess->isLocal())
394 {
395 m_bSuccess = true;
396 QDir dir(mFileAccess->absoluteFilePath());
397
398 dir.setSorting(QDir::Name | QDir::DirsFirst);
399 if(bFindHidden)
400 dir.setFilter(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot);
401 else
402 dir.setFilter(QDir::Files | QDir::Dirs | QDir::System | QDir::NoDotAndDotDot);
403
404 const QFileInfoList fiList = dir.entryInfoList();
405 if(fiList.isEmpty())
406 {
407 /*
408 Sadly Qt provides no error information making this case ambiguous.
409 A readability check is the best we can do.
410 */
411 m_bSuccess = dir.isReadable();
412 }
413 else
414 {
415 for(const QFileInfo& fi: fiList) // for each file...
416 {
417 if(ProgressProxy::wasCancelled())
418 break;
419
420 assert(fi.fileName() != "." && fi.fileName() != "..");
421
422 FileAccess fa;
423
424 fa.setFile(mFileAccess, fi);
425 pDirList->push_back(fa);
426 }
427 }
428 }
429 else
430 {
431 KIO::ListJob* pListJob = nullptr;

Callers

nothing calls this directly

Calls 15

fileNameMethod · 0.80
setFileMethod · 0.80
push_backMethod · 0.80
filterListMethod · 0.80
endMethod · 0.80
clearMethod · 0.45
absoluteFilePathMethod · 0.45
isLocalMethod · 0.45
isEmptyMethod · 0.45
isReadableMethod · 0.45
prettyAbsPathMethod · 0.45
enterDirMethod · 0.45

Tested by

no test coverage detected