Thread: Combining files

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    30

    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?

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    zip?

    Do you want all the files in one for security reasons?

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    30
    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.

  4. #4
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    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.

  5. #5
    Registered User
    Join Date
    Apr 2005
    Posts
    30
    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 =/

  6. #6
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  5. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM