views:

139

answers:

3

I want to place all my programs content in a compressed archive file as its starting to get quite large. I know theres a few libraries around like zlib but i dont know how to make them do what I want to do:

  • Be able to load textures/models etc from the file, curretly im using d3dx methods such as D3DXCreateTextureFromFileEx. I dont really want to have to write my own image loaders for the diffrent formats I want, so I need some way to be compatible with these d3d methods. I know they have a way to load from an in-memory file, would it be suitable to extract the file into memory somehow then load that?

  • Be able to use c++ streams with files in the compressed archive eg:
    std::zipstream file("data.zip:sounds/beep.wav", std::ios::in | std::ios::binary);

A: 

There are ready made libraries for this sort of thing. I'm afraid I don't know any names, but I suggest to google on the keywords "virtual file system".

Vilx-
To whoever downvoted this: Why do you think this is not helpful? I did point in a direction!
Vilx-
+2  A: 

I'd recommend looking at open source games (quake3 for example). Some of them are packing resources and have working implementations of "virtual file system", as Vilx noted. You might get some ideas.

begray
Firefox uses something akin to this, too, for extensions. In some cases this involves compression. Windows has some native APIs which treat zip files like folders...
Brian
A: 

There is an article entitled Programming a Virtual File System archived on flipcode that should provide what you need. If you have questions specific to that article, many former flipcode members now frequent the forums at DevMaster.net.

Judge Maygarden