File indexing completed on 2024-05-05 03:52:20

0001 /*
0002     This file is part of the KDE Baloo Project
0003     SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #include <QCoreApplication>
0009 #include <QCommandLineParser>
0010 #include <QElapsedTimer>
0011 #include <iostream>
0012 
0013 #include "filtereddiriterator.h"
0014 #include "fileindexerconfig.h"
0015 #include "util.h"
0016 
0017 using namespace Baloo;
0018 
0019 int main(int argc, char** argv)
0020 {
0021     QCoreApplication app(argc, argv);
0022 
0023     QCommandLineParser parser;
0024     parser.addPositionalArgument(QStringLiteral("folder"), QStringLiteral("Folder to test on"), QStringLiteral("folderName"));
0025     parser.process(app);
0026 
0027     std::unique_ptr<FileIndexerConfig> config;
0028 
0029     QStringList includeFolders;
0030     if (!parser.positionalArguments().isEmpty()) {
0031         QString folder = parser.positionalArguments().first();
0032         includeFolders << QFileInfo(folder).absoluteFilePath();
0033     } else {
0034         config.reset(new FileIndexerConfig);
0035         includeFolders = config->includeFolders();
0036     }
0037     QElapsedTimer timer;
0038     timer.start();
0039 
0040     int num = 0;
0041     for (const QString& dir : includeFolders) {
0042         FilteredDirIterator it(config.get(), dir);
0043         while (!it.next().isEmpty()) {
0044             num++;
0045         }
0046     }
0047 
0048     std::cout << "Num Files: " << num << std::endl;
0049     std::cout << "Elapsed: " << timer.elapsed() << std::endl;
0050     printIOUsage();
0051 
0052     return 0;
0053 }