PAK Last edited 10 months ago2024-01-19 00:25:30 UTC

PAK is a simple file archival format used by Quake and Half-Life. It consists simply of the concatenated uncompressed raw data of the containing files, followed by the table of contents with the content files' name, location, and size within the pak file.

It was used extensively in retail WON Half-Life and WON-era mods. Support for PAK files were dropped in early Steam Half-Life, but added back in the 2013 SteamPipe update.

The main advantage of using PAKs was that it reduced operating system filesystem overhead back when CPUs were slow, and disk access slower, in the late 90s and early 00s compared to today. It also neatly packages a complete set of content, and old mods like They Hunger used it to distribute expansions this way. The more resource heavy Source engine continues to use a proprietary archival format today, called VPK.

Several programs to open PAK files include PakScape and GCFScape (recommended).

Naming, loading order, precedence

PAK files are read only from the root of the game/mod folder (valve, gearbox, hunger, etc.). Only pak files named pak0.pak, pak1.pak, pak2.pak, ..., pakN.pak are loaded, in order. The engine stops loading on the first missing index, i.e. if there exists paks 0 through 2 but 3 is missing, then it won't load paks 4 and above even if they exists. If two or more paks contain the same file, the latest take precedence. Likewise, files in local filesystem take precedence over those in paks.

With the SteamPipe folder hierarchy (see link below for more info), pak files are loaded from _addon suffixed folders as well.

PAKs are limited to 2GiB in size.

Contents

While pak files can contain files of any format, generally only game assets are stored. Notably, WADs are often excluded and placed on the filesystem instead. Likewise for DLL files; DLLs inside PAKs may not load.

The complete path of files in PAKs are limited to 55 characters* long including the path separator slashes ("/") and file extension (including the dot). Hence, the deeper nested the folder entries, the shorter the available file name length is.

The path of files are stored in unknown narrow encoding (presumably your system's local ANSI encoding) so it is on you the modder to ensure to only use ASCII to avoid problems with mojibake.

A very similar limit for path length and encoding also applies to paths to assets (e.g. models, sprites, sounds) referenced in entities, so it's always good practice to be concise and to use ASCII. If paths longer than 55 characters* are unavoidable then you can't put those files in a PAK.

* 55 bytes when encoded in case you're using multi-byte encodings like UTF-8, BIG5, etc. Actually, please don't use multi-byte encodings for filenames anywhere in GoldSrc.

See also

Comments

You must log in to post a comment. You can login or register a new account.