-
Combining files
Hey, I notice that some files are actually more than one file composed together and I want to be able to use this in a small game engine I am going to try and write in the near future. By this I mean, I want a .x file, a script file, and perhaps textures (for example) all in a .pkg file. I already know of a method of creating these files... but how would I open the .pkg file and read each file separately and load them directly into memory, without having to create a temporary file to read from. Or would that actually be the best way?
-
zip?
Do you want all the files in one for security reasons?
-
I was thinking of using my own file format really... And I'd like to group them all together in one file so that it is harder for people to modify the file, so yes for some security although I am aware that someone could break my file format and modify data, the average user wouldn't be able to do that and this is only a Single-Player engine anyway :P
So basically I just want the files that make up an entity, such as an enemy which could include various parts (Mesh, collision mesh, scripts) in one file that I can create and read from.
-
Is your problem the format of the file, or the reading of it?
You could have a simple format like:
[resource_type][resource_size]
So in your file, you'll read a resource header into a struct. Then you'll know what type type of resource it is, and the size, so you'll know how much data to read.
-
Well I havent actually written anything yet. I'm starting the design of the engine before I actually code anything, and I was deciding on the best way of handling files. I just dont know a method of reading a file which is part of another file, such as a .x file. :s I was thinking of simply copying the binary data from the .pkg file, and creating a temporary .x file to load the mesh from. So its just loading something such as a mesh directly from the combined file I'm having trouble with. I dont know how to do that =/
-
If the api that you're using to load the .x file doesn't support loading resources from memory, then you'll have to use a temp file.