Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtual Filesystem with C/C++ under Windows [closed]

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?

like image 274
Christian Ivicevic Avatar asked Jun 13 '11 13:06

Christian Ivicevic


2 Answers

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.)

like image 149
Mat Avatar answered Sep 25 '22 06:09

Mat


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.

like image 22
mah Avatar answered Sep 25 '22 06:09

mah