Wrap - mtalyat/Minty GitHub Wiki

A Wrap file is very similar to a PAK file. In fact, it was inspired from it. A Wrap file is an archive file that will compile multiple files into one, larger file. It will optionally compress files over a certain amount of bytes. A Wrap, functionally, can act like a virtual file system, when used in the engine.

The name Wrap comes "Wrapper", as in a mint candy wrapper. And because you can wrap assets up into one file.

Wrap Files

Wrap file diagram.

A Wrap is split into 3 parts. The first part is the Header, which provides meta information about the Wrap itself. The second part is the list of Entries, containing meta data about each file stored within the Wrap. The third part is the files themselves.

Header

Below is a list of attributes for the Wrap header.

Attribute Description
id Contains the characters "WRAP". This is used to verify that the file is in fact, a Wrap file.
type Contains the type of Wrap file. The File type is used to store files. The Update type is used patch/override existing data in another Wrap file.
wrapVersion This is the version of WRAP the file was last generated with. This is stored in case there was an update to Wrap, which could change how the data is written or read.
contentVersion This is the version of the contents. This is mostly used to determine the age of the contents of the file, as some games may use this value for various things.
basePath This is the virtual base path of all files within the Wrap. For example, if the base path is "MyFolder/", all files within the Wrap would need to be accessed by prepending "MyFolder/" to their paths.
name This is the name of this Wrap file. It has no special purpose other than for identification.
entryCount This is the number of entries in this Wrap file. Used to know how many times to iterate over the entries list.

Entries List

Below is a list of attributes for each Entry in the Entries list.

Attribute Description
path This is the path to the file.
compressionLevel This is the level of the compression used on the file. It could be anywhere from 0-9, where 0 is no compression, 1 is fast compression, and 9 is high quality compression.
reservedSize This is the total space in bytes that the data has within the Wrap file. If the file is edited, it can grow up to this size. If it grows over this size, it will need to be moved within the list of files.
compressionSize This is the size of the compressed data in bytes. This is the number of bytes to read from the file within the list of files.
uncompressedSize This is the size of the uncompressed data in bytes. This is the size needed to create the buffer to load the data into when uncompressing.
offset This is the offset of this file within the list of files.

List of Files

This is where the files are stored.

Wrap file example in a hex editor.

Wrapper

The Wrapper is a helper program used to wrap and unwrap files on the disk. It can be found here. It can be used from the command line. Its usage is as follows:

wrapper <action> <path> [options]

Actions

Action Description Example
wrap Create a new Wrap file from a directory. wrapper wrap Assets/
unwrap Create a new directory from a Wrap file. wrapper unwrap Assets.wrap
update Update an existing Wrap file with new files. This will increment the content version of the Wrap file by 1. No action will be taken if the files within the given directory match the files within the existing Wrap file. By default, the output file will be the name of the directory .wrap, but it can also be specified manually. wrapper update Assets/ Assets.wrap
info Show information about a Wrap file. wrapper info Assets.wrap
help Shows a help message with this information. wrapper or wrapper help

Path

For wrap and update actions, the path must lead to the directory to use. For unwrap and info, the path must lead to a Wrap file to use.

For update, an additional path can be provided, leading to the output file. For unwrap, an additional path can be provided, leading to the output directory.

Options

Option Description Example
-o <path>, --output <path> Output path for the Wrap file or directory. wrapper wrap Assets/ -o My/Output/Directory/Assets.wrap
-n <name>, --name <name> Name of the Wrap file. This is different from the file name. wrapper wrap Assets/ -n "My Wrap File"
-b <path>, `--base Specifies the base path used within the Wrap file. wrapper wrap Assets/ -b Defaults/
-v <num>, --version <num> Specifies the content version of the Wrap file. wrapper wrap Assets/ -v 23
-t <type>, --type <type> Type of the Wrap file. Expects file or update. Defaults to file. wrapper wrap Assets/ -t update
-c <level>, --compression <level> The default file compression level. Expects none, fast, low, default, best, high, or a number between 1 and 9. Defaults to default (level 6). wrapper wrap Assets/ -c none
-h, --help Shows a help message with this information. wrapper -h
⚠️ **GitHub.com Fallback** ⚠️