How to use filesystem boost copy_file with qrc resources?

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

How to use filesystem boost copy_file with qrc resources?

Post by sirherrbatka » 15 Oct 2013, 17:52

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: 5134
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post by Zini » 15 Oct 2013, 20:05

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: 5134
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post by Zini » 15 Oct 2013, 20:08

But it seems that OpenCS currently does not support the --resource switch. Needs to be added (in editor.cpp).

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: How to use filesystem boost copy_file with qrc resources

Post by sirherrbatka » 15 Oct 2013, 20:29

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: 5134
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post by Zini » 15 Oct 2013, 21:06

Because we are using STL and boost file stuff everywhere else, including parts that are used by the editor.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: How to use filesystem boost copy_file with qrc resources

Post by sirherrbatka » 15 Oct 2013, 21:41

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: 5134
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post by Zini » 16 Oct 2013, 08:11

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: 2121
Joined: 07 Aug 2011, 17:21

Re: How to use filesystem boost copy_file with qrc resources

Post by sirherrbatka » 16 Oct 2013, 08:21

yes, I already figure this out. That's why I want to do it! :lol:

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: How to use filesystem boost copy_file with qrc resources

Post by sirherrbatka » 16 Oct 2013, 12:20

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: 5134
Joined: 06 Aug 2011, 15:16

Re: How to use filesystem boost copy_file with qrc resources

Post by Zini » 16 Oct 2013, 12:26

Have a look at Editor::setupDataFiles.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests