Many games choose to store their resources in packages instead of shipping the potentially thousands of individual files directly. This is sometimes an attempt at tamper-proofing, but mostly it is about performance. Try copying a thousand 1 KiB files from one drive to another, then copy a single 1 MiB file on the same way – the former operation will take many times longer.
A good choice for a package format is the well known .zip archive. It’s not necessarily well-designed, but it decompresses fast and you definitely won’t have any problems finding tools to create, modify and extract .zip archives. Thus, when I started work on a file system abstraction layer for my future games, seamless .zip support was one of my main goals (I may also add 7-Zip at a later time just for fun).
Here is the design I came up with after exploring the file system APIs available on Windows, WinRT and Linux:
You may notice some rather radical design choices in my File class: there
are no Open()
or Close()
methods and there is
no Seek()
method, either – each read or write specifies
the absolute position without requiring the file to be opened.