Page 1 of 4

How to use filesystem boost copy_file with qrc resources?

Posted: 15 Oct 2013, 17:52
by sirherrbatka
I finally started to actually program anything related to my current task :roll:

Before comitting anything I would like to check if I'm not doing here something increadible stupid. At the moment I'm doing it like this:

Code: Select all

QFile filters("qrc:///defaultfilters.omwaddon.project");
QFileInfo info(filters);
boost::filesystem::path filters_path(info.absoluteFilePath().toUtf8().constData());
boost::filesystem::copy_file( filters_path, mProjectPath );
Is it correct?

Re: How to use filesystem boost copy_file with qrc resources

Posted: 15 Oct 2013, 20:05
by Zini
Not really. Forget about QFile. And do not add the default filter file as a Qt resource. The file needs to be stored in the resource path (we have several OpenMW resource files that can serve as an example).

Re: How to use filesystem boost copy_file with qrc resources

Posted: 15 Oct 2013, 20:08
by Zini
But it seems that OpenCS currently does not support the --resource switch. Needs to be added (in editor.cpp).

Re: How to use filesystem boost copy_file with qrc resources

Posted: 15 Oct 2013, 20:29
by sirherrbatka
hm, right.

Zini, I wanted to ask about this for a long time. Why we are not using qt file stuff inside editor?

Re: How to use filesystem boost copy_file with qrc resources

Posted: 15 Oct 2013, 21:06
by Zini
Because we are using STL and boost file stuff everywhere else, including parts that are used by the editor.

Re: How to use filesystem boost copy_file with qrc resources

Posted: 15 Oct 2013, 21:41
by sirherrbatka
Oh well, I want to TRY implementing switch but I'm not sure if I will be able to do it.

Can I take it?

Re: How to use filesystem boost copy_file with qrc resources

Posted: 16 Oct 2013, 08:11
by Zini
That is trivially easy. We already have it in OpenMW (main.cpp). Just copy it over. Then the only thing left to do is to hand down the resources values to the place where you need it. Shouldn't be too hard.

Re: How to use filesystem boost copy_file with qrc resources

Posted: 16 Oct 2013, 08:21
by sirherrbatka
yes, I already figure this out. That's why I want to do it! :lol:

Re: How to use filesystem boost copy_file with qrc resources

Posted: 16 Oct 2013, 12:20
by sirherrbatka
Ok, I'm idiot: I don't know how to complete this resources switch, and where engine sets mresourcedir to default value. And I don't quite feel like I'm doing something that makes sense here. If you want to laugh, please take a look at https://github.com/sirherrbatka/openmw/tree/filters

Zini, forgive me, it is not that trivial.

Re: How to use filesystem boost copy_file with qrc resources

Posted: 16 Oct 2013, 12:26
by Zini
Have a look at Editor::setupDataFiles.