NVault

From AlliedModders Wiki
Revision as of 21:22, 21 August 2010 by TheFrozenFire (talk | contribs) (Added Editing nVault Files section)
Jump to: navigation, search

nVault is the standard flatfile database format for AMXX, used to store all sorts of data. nVault functions essentially as a key->value store, with an additional timestamp for each entry.

nVault Format Specification

nVault is a non-delimited binary key->value store which is dependent upon the endianness of the system by which it is generated.

File Header

Beginning each nVault file is a 4-byte, int32 "magic value" which indicates the endianness of the file. This "magic value" represents the string "nVLT" in ASCII, or 0x6E564C54 in hex, when unpacked using the proper endian.

Following is a two-byte, int16 format version specification. The version specification as of the writing of this article decodes as the integer 2, or 0x0200 in hex, when unpacked using the proper endian.

Next is a four-byte, int32 entries enumeration, indicating how many entries the file contains.

Entries

Each entry in the file takes the format: <int32 timestamp><int8 key length><int16 value length><key><value>

The file should be read in using an iteration statement, up to the number of entries specified in the entries enumeration in the header.

The four-byte, int32 timestamp indicates when the entry was written to the file. The one-byte, int8 key length indicates how many bytes the key length is. The two-byte, int16 value length indicates how many bytes the value length is.

When reading each entry, read in the timestamp, the key length and the value length, as they are of known length. Then, read in the key as per the length specified in the key length, and the value length as per the length specified in the value length.

Editing nVault Files

Should you need to make manual edits to an nVault file, there are a few tools available for doing so.

Name Maintainer Release Date
nVault Reader [1] P34nut January 10th, 2007
nVault Editor [2] Bugsy February 5th, 2008