Mega Files (extension: .MEG) in Petroglyph's games are used to store the collection of game files. By packing these files into a single large file, the operating-system overhead of storing and opening each individual file is removed and it helps avoid fragmentation.
Each Mega File begins with a header, followed by the Filename Table, the File Table and finally, the file data.
Header: +0000h numFilenames uint32 ; Number of filenames in the Filename Table +0004h numFiles uint32 ; Number of files in the File Table Filename Table record: +0000h length uint16 ; Length of the filename, in characters +0004h name length ; The ASCII filename File Table record: +0000h crc uint32 ; CRC-32 of the filename +0004h index uint32 ; Index of this record in the table +0008h size uint32 ; Size of the file, in bytes +000Ch start uint32 ; Start of the file, in bytes +0010h name uint32 ; Index in the Filename Table of the filename
Notes:
It is common or just possible for Petroglyph's games to have multiple Mega Files, and even Mega Files for user mods. All used Mega Files are listed in MegaFiles.xml in a game directory. Petroglyph's games read this file and, load all Mega Files and merge their File Table to create one Master File Table. If a file occurs in multiple Mega Files, the file in the Mega File listed last in MegaFiles.xml will be used.