get original file name of resource in qrc file
How can I get the original file name from the qrc resource file?
qrc entry: :/my/file (somefile.txt)
Here, I expect to see (atleast):
QFile file(":/my/file"); QResource r(file.fileName) qDebug() << r.fileName(); qDebug() << r.absoluteFilePath();
Do I misunderstand the doc page, or am I just doing it wrong
How can I get the original file name from the qrc resource file
You can't. The resources don't store that information once they're compiled. This information is useless in deployed app. If I had a file, say
D:/MyDirectory/foo.txt, what good would that be on someone else's computer? There might not even be
QFilemethods operate on the resource file, not on the original file so all paths will point to the resource file.
What would you need that path for?
It would actually just make things easier.
I would like to generalize this procedure to e.g.
Qresource::OriginalFileName()returns the original file name e.g.
Now, I am required to (for each file):
QString newLocation = QString(tempdir + tempdir.seperator() + QString("myNewFileName.txt")); QFile::copy(":/my/file", newLocation);
It just seems tedious and not very efficient.
But thanks for clearing it up though,