Virtual Filesystem with C/C++ under Windows [closed]
Asked Answered
A

3

5

I am currently developing a game which simulates an operating system. Therefore i need an ingame filesystem. Currently, i am using zziplib to be able to load files from a zip archive, however this is a readonly "filesystem" and i need a way to write new files and serialize them afterwards (and deserializing them during the next execution)! Are there any useful libraries out there in the wild to be used or should i write one for myself based on any ones?

Anatollo answered 13/6, 2011 at 13:56 Comment(0)
W
6

This is probably one of the places where using a simple database as a filesystem makes sens.

Use something like sqlite to store the data (with paths as keys, blobs as data, or something like that).

One of the advantages of doing this is that you don't actually have to worry about the storage, and you can use existing database tools to view/edit the data "offline" rather than having to write your own. (Plus you can store other game info in there as well.)

Woothen answered 13/6, 2011 at 14:5 Comment(2)
Absolutely. SQLite has been used by other games for the very same reason.Libertylibia
I totally forgot, that i might use SQL which indeed is very cool and can be included easily! Thanks for the reminder!Anatollo
C
5

You might check out PicoStorage and Embedded File System in C++. I haven't directly used either but I've looked at them both. Embedded File System does have a dependency which could be a show stopper -- it requires Qt to be linked in. Perhaps that could be removed, but it uses it mainly for QString and QFile (and would have no reason to require the UI).

Update, 9 years later: As commented, the above links no longer work. This alternative link for PicoStorage may be viable (I was able to download the source from there but I've made no effort to validate it) but I cannot locate a modern equivalent for EFS.

Chum answered 13/6, 2011 at 14:27 Comment(2)
Qt as a dependency would be an overkill - i'll rather use sqlite! But thanks for the info.Anatollo
As of today, both links are broken.Recommendation
C
2

My six pence on top of the answers above. SolFS (now CBFS Storage) and CodebaseFS provide virtual file system capabilities; both have an API for C/C++ and appear to do exactly what you are asking about. Still... the scale of your task is not clear for me. Does your game need to manage dozens, hundreds, zounds, ... of files? What are the sizes of those files? Etc, etc. I would raise these questions before looking for an appropriate solution.

Chivy answered 13/6, 2011 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.