Virtual File System question...

Started by
3 comments, last by JY 18 years, 8 months ago
So I am contemplating how I would use resource files (not windows, but generic) in my game, so my data is hidden and zipped (gzip). Most tools I use (like FMOD) open from a file on the harddrive... So if everything is already stored in memory in a virtual file system, how would I go about passing them to these tools as if they were on the harddrive? How do normal games do it? Thanks! <3 visage
Advertisement
Many libraries allow you to specify callback functions for reading and writing. You'd have to use those.
Haven't used FMOD in years, so I don't know if its changed too much, but I do remember I was able to load stuff out of resource files (quake2 pak files) by writing and specifying the appropiate callback functions.

To handle resource files, there are typically 2 ways I've seen APIs/libraries support them:

+Load the file from memory. Your responsible for putting the file into RAM and you pass a pointer to an appropiate API/library function that loads the file.

+Pass a file pointer (FILE*) to the appropiate API/library function and specify callbacks that deal with seeking within the file. What's important here is that you correctly handle seeking to the beginning and/or end of the file since you can't simply seek to the beginning/end of the resource file.

If an API/library only supports taking a filename and loading the file itself, then (AFAIK) it's not possible to use the API/library with resource files.
I basically do it how Catafriggm suggests. In my virtual filesystem class I wrote my own functions that act like FILE* stream. If you need some example code on how I went about it PM me and I'll gladly send you my class as reference. I only have the reading functions done so far though, i havent made any which will allow you to modify whats in the file. It's on my todo list. :D
I'm not sure about licensing issues, but you could use a virtual disk driver like this one:

http://chitchat.at.infoseek.co.jp/vmware/vdk.html#top

Then you can use normal file handling functions instead of writing your own I/O subsystem.
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan

This topic is closed to new replies.

Advertisement