Virtual Files

86c043eaa94314399cc064d153a93d26
0
_NOISEcore 101 Sep 15, 2011 at 19:17

Yes, the title is quite ironic. Virtual files. Isn’t any file virtual? Anyho.

Say that I write a file format used for 3D models, which combines the 3D files with the textures, AO, …

How would I be able to read that file without have to create temporary files out of that.

Basically:
5 files into 1 file to write
to read: load them all during runtime while not having to create 5 actual files (so some sort of buffer system)

EDIT: Forgot to mention which language, dumb me.. It’s C++

5 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Sep 15, 2011 at 19:49

Why would you need to create temporary files? Just read the file into one big memory buffer, then set up pointers to the individual resources within that, and access them as you please.

86c043eaa94314399cc064d153a93d26
0
_NOISEcore 101 Sep 15, 2011 at 20:34

Yes, that was my question.

I have never had that much experience with file streaming,
and I didn’t know that that was possible.

But now that I think of it..
Thank you :)

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 104 Sep 16, 2011 at 10:30

You can actually manage the whole harddisk from your own program just out of one file, set up access pointers, defragment, find writable positions… thats how sparse voxel octrees work, being able to find all the exact information out of one file so it quickly streams.
You can do the same thing with ram, just allocate it all into a single static buffer, then manage the internals yourself with your own code.

86c043eaa94314399cc064d153a93d26
0
_NOISEcore 101 Sep 16, 2011 at 14:56

Ok.

So basically write it all into one file
And then when reading, read it into one buffer, and then (possibly)
Set up multiple pointers pointing to positions in the buffer which represent
beginnings & endings of files within the “master” file.

Or am I mistaken?

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 104 Sep 16, 2011 at 15:39

You could do it like that, but think, how are you going to reduce access times from just iterating through the list of files until you hit the right string comparison? :) Remember, this is how all “file packs” or “file wads” (like from doom) work, but you need to be able to extract the right information as quick as possible.

If you wanted to release a game, its good to do, its tacky (carmageddon was sold with about 10 million separate files in the program hehe) releasing a game with all the media in separate files people can just import into editors so simply, if you pack them all away you can add compression whilst copy protecting your media, visual studio can pack media in with the exe file, also.

[EDIT] actually, if you just wanted to load the whole thing, what reedbeta said would be all you need to do, but if you wanted to say load each level one at a time, you need the extra searching pointers.[EDIT]