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 "fileindexerconfig.h"
0009 
0010 #include <QCoreApplication>
0011 #include <QCommandLineParser>
0012 #include <QFileInfo>
0013 #include <QMimeDatabase>
0014 
0015 #include <iostream>
0016 
0017 int main(int argc, char** argv)
0018 {
0019     QCoreApplication app(argc, argv);
0020 
0021     QCommandLineParser parser;
0022     parser.addPositionalArgument(QStringLiteral("file"), QStringLiteral("The file url"));
0023     parser.process(app);
0024 
0025     if (parser.positionalArguments().isEmpty()) {
0026         parser.showHelp(1);
0027     }
0028 
0029     Baloo::FileIndexerConfig config;
0030 
0031     const QString arg = parser.positionalArguments().first();
0032     const QString url = QFileInfo(arg).absoluteFilePath();
0033 
0034     bool shouldIndex = config.shouldBeIndexed(url);
0035 
0036     QMimeDatabase m_mimeDb;
0037     QString mimetype = m_mimeDb.mimeTypeForFile(url).name();
0038     QString fastMimetype = m_mimeDb.mimeTypeForFile(url, QMimeDatabase::MatchExtension).name();
0039 
0040     bool shouldIndexMimetype = config.shouldMimeTypeBeIndexed(fastMimetype);
0041     std::cout << url.toUtf8().constData() << "\n"
0042               << "Should Index: " << std::boolalpha << shouldIndex << "\n"
0043               << "Should Index Mimetype: " << std::boolalpha << shouldIndexMimetype << "\n"
0044               << "Fast Mimetype: " << fastMimetype.toUtf8().constData() << std::endl
0045               << "Slow Mimetype: " << mimetype.toUtf8().constData() << std::endl;
0046 
0047     return 0; //app.exec();
0048 }