Baloo Widgets

extractor.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "extractorutil_p.h"
8
9#include <QCommandLineParser>
10#include <QCoreApplication>
11#include <QDataStream>
12#include <QFile>
13#include <QMimeDatabase>
14
15#include <KFileMetaData/Extractor>
16#include <KFileMetaData/ExtractorCollection>
17#include <KFileMetaData/MimeUtils>
18#include <KFileMetaData/SimpleExtractionResult>
19
20#include <iostream>
21
22int main(int argc, char **argv)
23{
24 QCoreApplication app(argc, argv);
25
26 QCommandLineParser parser;
28 parser.process(app);
29
30 if (parser.positionalArguments().size() != 1) {
31 parser.showHelp(1);
32 }
33
34 const QString url = parser.positionalArguments().constFirst();
36
37 KFileMetaData::SimpleExtractionResult result(url, mimetype, KFileMetaData::ExtractionResult::ExtractMetaData);
39
40 const QList<KFileMetaData::Extractor *> exList = collection.fetchExtractors(mimetype);
41
42 for (KFileMetaData::Extractor *ex : exList) {
43 ex->extract(&result);
44 }
45
46 QFile out;
47 out.open(stdout, QIODevice::WriteOnly);
48 QDataStream stream(&out);
49
50 stream << result.properties();
51
52 return 0;
53}
QList< Extractor * > fetchExtractors(const QString &mimetype) const
QMimeType strictMimeType(const QString &filePath, const QMimeDatabase &db)
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax)
QStringList positionalArguments() const const
void process(const QCoreApplication &app)
void showHelp(int exitCode)
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
const T & constFirst() const const
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:45:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.