From e883ef619721e905cf2b5310c9a1e14665fba6b9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 10 Jul 2018 13:59:10 +0200 Subject: [PATCH] rcc: Add a --list-mapping option to output both resource and real paths The --list option outputs only the file system paths, but does not tell us where those files end up in the resource file system. This is unfortunate because the resource paths are possibly the most interesting thing to be expected from a listing of resource files. Add an option that outputs a full mapping. This is also useful for tools that need to resolve files for resource paths from outside the application using the resources. [ChangeLog][Tools][rcc] Added a --list-mapping option which shows a mapping of resource paths to file system paths. Change-Id: I0cb57fe091ef78b4a9eca8be2fc53278ae50cc11 Reviewed-by: Oswald Buddenhagen Reviewed-by: hjk --- src/tools/rcc/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index fba47b74c3..12f986b1e2 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -151,6 +151,10 @@ int runRcc(int argc, char *argv[]) QCommandLineOption listOption(QStringLiteral("list"), QStringLiteral("Only list .qrc file entries, do not generate code.")); parser.addOption(listOption); + QCommandLineOption mapOption(QStringLiteral("list-mapping"), + QStringLiteral("Only output a mapping of resource paths to file system paths defined in the .qrc file, do not generate code.")); + parser.addOption(mapOption); + QCommandLineOption projectOption(QStringLiteral("project"), QStringLiteral("Output a resource file containing all files from the current directory.")); parser.addOption(projectOption); @@ -207,6 +211,7 @@ int runRcc(int argc, char *argv[]) library.setVerbose(true); const bool list = parser.isSet(listOption); + const bool map = parser.isSet(mapOption); const bool projectRequested = parser.isSet(projectOption); const QStringList filenamesIn = parser.positionalArguments(); @@ -242,7 +247,7 @@ int runRcc(int argc, char *argv[]) library.setInputFiles(filenamesIn); - if (!library.readFiles(list, errorDevice)) + if (!library.readFiles(list || map, errorDevice)) return 1; QFile out; @@ -294,6 +299,17 @@ int runRcc(int argc, char *argv[]) return 0; } + if (map) { + const RCCResourceLibrary::ResourceDataFileMap data = library.resourceDataFileMap(); + for (auto it = data.begin(), end = data.end(); it != end; ++it) { + out.write(qPrintable(it.key())); + out.write("\t"); + out.write(qPrintable(QDir::cleanPath(it.value()))); + out.write("\n"); + } + return 0; + } + QFile temp; if (!tempFilename.isEmpty()) { temp.setFileName(tempFilename);