How to use filesystem boost copy_file with qrc resources?

Involved development of the OpenMW construction set.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

How to use filesystem boost copy_file with qrc resources?

Post 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?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post 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).
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post by Zini »

But it seems that OpenCS currently does not support the --resource switch. Needs to be added (in editor.cpp).
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: How to use filesystem boost copy_file with qrc resources

Post 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?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post by Zini »

Because we are using STL and boost file stuff everywhere else, including parts that are used by the editor.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: How to use filesystem boost copy_file with qrc resources

Post 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?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post 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.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: How to use filesystem boost copy_file with qrc resources

Post by sirherrbatka »

yes, I already figure this out. That's why I want to do it! :lol:
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: How to use filesystem boost copy_file with qrc resources

Post 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.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post by Zini »

Have a look at Editor::setupDataFiles.
Post Reply