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 <oswald.buddenhagen@qt.io> Reviewed-by: hjk <hjk@qt.io>bb10
parent
d1dcc4d8cd
commit
e883ef6197
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue