# How to pack the game files into one without using any file compressor?

Well, one example is this file of the game The Sims 2 for PS2: quickdat.arc. The file contains this .arc extension, but it's no one an archive file and it contains some data of the game inside. How can I do this? Put so many files in one?

How to do something like this? All the game files inside one without using a file compressor?

• May 3, 2013 at 22:38
• What language and platform are you using, and why don't you want any compression? May 3, 2013 at 22:39
• You can simply use a standard zip library such as dotnetzip.codeplex.com to combine everything. It also support fetching individual files out of the archive. Note that zip is not a compressed file format. May 4, 2013 at 0:50

The process to create such an archive file is fairly straightforward. You'll want to read in the raw bytes of every input file, writing them to a single in-memory output buffer as you go.

You will also need to keep track of where in the output buffer you begin to write each file. Without this "table of contents" information, it will be very difficult to get the individual file bytes out of the archive later.

Once you've copied all the input files into the buffer, open the final output file and write the table-of-contents information into it. Then write the output buffer that contains the raw file bytes.

Then, to read data from the archive file later, you can open it and read the table-of-contents chunk. That will give you the offsets (relative to the end of the table-of-contents) of each file in the archive.

The above will get you a basic implementation. There are, of course, many variations you can make on this theme, for example by storing more file metadata, or providing support for buffering the I/O operations in some fashion, or precomputing the table of contents data based on just the file sizes so you can stream the archive output to disk instead of requiring it to all exist in memory at once. Whether or not these are relevant to you depend on your specific needs.

Some very straightforward and naive pseudo-code in a C#-like language might be:

var archive = new List<byte>();
var contents = new Dictionary<string, int>()

var files = /* a list of all input files that will be in the archive */

foreach (var file in files) {
var bytes = ReadAllBytes(file);

// We're about to write the file to the archive, so store the offset.
contents[file] = archive.Count;

// Write the actual bytes.
}

// Now write the final archive.
var output = /* name of the output file */
foreach (var pair in contents) {
WriteToFile(output, pair.Key);
WriteToFile(output, pair.Value);
}

WriteToFile(output, archive);


Very simply Files are a collection of bytes that can be interpreted anyway you choose (but will only be interpreted correctly following the proper steps for each individual file). The extension is used as a tip for how you should go about interpreting this file. When a developer makes a file-type you've never heard of it's because it's his/her own custom file-type that suits his/her own purposes, or he/she just doesn't want you to know what file-type it is at all by making a random extension.

You can do something like this by reading the byte data of files, and writing it back into a larger one. Nothing is stopping you from writing the file data of several files into one larger one as long as you know how to read the individual file data back to suit your own needs.

This is how compression works. It takes the original file data and runs algorithms to create new condensed file data that can be reworked using similar techniques into the original file. For example a .zip extension just tells you that the file data is compressed data using the zip format, and will be pretty useless to you interpreted in any other way.

Read up on basic file input/output in your language of choice for the actual HOWTO of working with file data.