File indexing completed on 2024-04-14 03:53:42

0001 /*
0002     SPDX-FileCopyrightText: 2014 Frank Reininghaus <frank78ac@googlemail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include <kio/listjob.h>
0008 
0009 #include <iostream>
0010 
0011 #include <QCoreApplication>
0012 #include <QDebug>
0013 #include <QDir>
0014 #include <QUrl>
0015 
0016 int main(int argc, char **argv)
0017 {
0018     if (argc < 2) {
0019         qWarning() << "Expected a path or URL.";
0020         return 1;
0021     }
0022 
0023     QCoreApplication app(argc, argv);
0024     quint64 entriesListed = 0;
0025 
0026     for (int i = 1; i < argc; ++i) {
0027         QUrl url = QUrl::fromUserInput(QString::fromLocal8Bit(argv[i]), QDir::currentPath());
0028         qDebug() << "Starting listJob for the URL:" << url;
0029 
0030         KIO::ListJob *job = KIO::listDir(url, KIO::HideProgressInfo);
0031         job->setUiDelegate(nullptr);
0032         job->addMetaData(QStringLiteral("details"), QString::number(KIO::StatDefaultDetails));
0033 
0034         QObject::connect(job, &KIO::ListJob::entries, [&entriesListed](KIO::Job *, const KIO::UDSEntryList &entries) {
0035             entriesListed += entries.size();
0036             qDebug() << "Listed" << entriesListed << "files.";
0037         });
0038     }
0039 
0040     return app.exec();
0041 }