Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: cross-platform c++ resource container library?  (Read 10397 times)

0 Members and 1 Guest are viewing this topic.

nietaki

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://almost-done.net
cross-platform c++ resource container library?
« on: January 07, 2012, 03:20:54 pm »
I spent a better part of today searching the web for a good library/way to store resource files in packages in my project. There were many nice leads, but none of them seemed right for me.

Here's what I mean by good:

- cross-platform (my team already develops on linux, windows and OSX)
- c++, not c - I've got enough problems as it is without linking my c++ code to c
- the compression isn't a priority, the main objective is to minimize the number of reads from hdd
- easy to use/build automatically with CMake (?)

and what I found:
- the hailed zlib doesn't seem to have cross platform c++ wrapper
- zipios++ is a long dead beta project
- http://icculus.org/physfs/ looks great, but also lacks the wrappers

...and so on and on.

Surely one of you guys knows/has used a good alternative. As I said, I don't specifically need zip, just a way to store multiple files in one file (preferably in a semi-structured way).

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
cross-platform c++ resource container library?
« Reply #1 on: January 07, 2012, 04:15:39 pm »
Currently I also search for such a library ;)

However I don't think C should be a big problem if the library follows a clean code style and is well documented. I'm probably having a look at PhysicsFS. There is also a code for sf::InputStream integration on the wiki, and it seems that there are other C++ wrappers on the internet...

Additionally I've heard about snappy, but it's rather a compression library. I would like further suggestions, too :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
cross-platform c++ resource container library?
« Reply #2 on: January 07, 2012, 04:47:16 pm »
just started playing with physfs/ , great so far. I didnt get static lib working just yet but I'm not bothered right now.

physfs I'm using as c right now, no problems for me.

I will be building it into the engine class and using it to manage all resources in the end , unless I find something better.

zlib is not cross platform, why?

the other option would be to just write a decompression thing similar, but why reinvent the wheel.....there is loads of c++ examples around though. - I would only be doing this to make the code smaller and dependencies less.

caracal

  • Newbie
  • *
  • Posts: 19
    • View Profile
cross-platform c++ resource container library?
« Reply #3 on: January 07, 2012, 05:16:52 pm »
Try googles snappy library http://code.google.com/p/snappy/ the readme is here http://code.google.com/p/snappy/source/browse/trunk/README

I am looking at packing my data into Googles protocol buffers and compressing that with snappy.

Personally I would use any decent zip library because zip is supported on every platform its fast with decent compression and it does both compression and archiving.

nietaki

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://almost-done.net
cross-platform c++ resource container library?
« Reply #4 on: January 07, 2012, 10:32:11 pm »
One more thing I found:
zlib is bundled with minizip a c library which can perform .zip file operations. And on it's homepage I found a mention of Daniel Godson's C++ wrapper (with an already dead link). But searching for the code on Koders.com I found something else:
http://www.koders.com/cpp/fid111F28C8BEF7DCD0A18FD13F7108BAEC218ED74D.aspx?s=nanohive+unzipper#L38
The Unzipper class is part of a larger project which should work both under Windows and Linux. The files interesting to us are free to use and they themselves use the zlib library.

I won't tamper with it just yet, but it looks pretty promising, I think I'll be trying to get it working some time soon...

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
cross-platform c++ resource container library?
« Reply #5 on: January 08, 2012, 08:42:03 am »
If you really only want to pack multiple files into a container, why not do it yourself? It's quite simple to do (an index with offsets to the files and sizes and the data itself). You can even apply compression before you save and decompression before you load.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
cross-platform c++ resource container library?
« Reply #6 on: January 08, 2012, 04:17:19 pm »
Does anybody know a proper wrapper around the 7z/LZMA API? PhysicsFS encapsulates that very nicely, but unfortunately it doesn't provide advanced features like password protection.

The LZMA SDK has one of the worst documented APIs I've ever seen... :|
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Oberon

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • My Github profile
cross-platform c++ resource container library?
« Reply #7 on: January 08, 2012, 06:34:46 pm »
It's not documented at all (apart from one or two comments). :x But you *can* understand the API. Start with <7z SDK dir>\CPP\7zip\UI\Client7z, which is an minimal example. It demonstrates opening, writing to and displaying the contents of an archive.

asdatapel

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
cross-platform c++ resource container library?
« Reply #8 on: January 10, 2012, 11:21:32 pm »
Quote from: "Tank"
If you really only want to pack multiple files into a container, why not do it yourself? It's quite simple to do (an index with offsets to the files and sizes and the data itself). You can even apply compression before you save and decompression before you load.


Could you show a code sample or link me to a resource. It'd be very helpful

Tau Sudan

  • Newbie
  • *
  • Posts: 5
    • View Profile
cross-platform c++ resource container library?
« Reply #9 on: January 11, 2012, 09:04:05 am »
Quote from: "asdatapel"
Quote from: "Tank"
If you really only want to pack multiple files into a container, why not do it yourself? It's quite simple to do (an index with offsets to the files and sizes and the data itself). You can even apply compression before you save and decompression before you load.


Could you show a code sample or link me to a resource. It'd be very helpful


That is actually something that would be a good exercise in a 1st year course in programming.  Hell, if I teach again, I'll probably do it.

open file
read in "header bytes" as you've defined them
read in the number of bytes required for each file and store them as appropriate in variable
close file
do what you want with the data

Similarly for saving.


If you don't know how to do any one of those operations in your language of choice, then, in all seriousness, you need to buy a book, or take a class.

For books, I would recommend any of the O'Reilly Learning series for what ever programming language you are programming (should it exist), or the Dietel & Dietel How to Program series.  The selection of the D&D books is extensive.  So, I'd be surprised if they don't have the language that you're looking for.

When it comes to courses, for practical programming, you'd be better off finding a technical college than a University.  Any intro course should do… should.

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
cross-platform c++ resource container library?
« Reply #10 on: January 11, 2012, 10:39:13 am »
Quote from: "asdatapel"
Quote from: "Tank"
If you really only want to pack multiple files into a container, why not do it yourself? It's quite simple to do (an index with offsets to the files and sizes and the data itself). You can even apply compression before you save and decompression before you load.


Could you show a code sample or link me to a resource. It'd be very helpful
This article on the Gamedev.net archive site may be of interest to you.