This is the specifications for the archive file which is handled by the Game Extractor plugin Archive_VPK_2.

Endian Order:Little Endian
Compression:None
Encryption:None


This format is used by the following Games:
Counter-Strike: Global Offensive *.vpk
Counter-Strike: Source *.vpk
Day of Defeat: Source *.vpk
Day Of Infamy *.vpk
The Ship *.vpk
Half-Life 2 *.vpk
Half-Life: Episode 1 *.vpk
Half-Life: Episode 2 *.vpk
Half-Life: Lost Coast *.vpk
Half-Life 2: Deathmatch *.vpk
Half-Life: Source *.vpk
Insurgency *.vpk
Portal *.vpk
Team Fortress 2 *.vpk
Transmissions Element 120 *.vpk


This is the format specification information:
 
// _dir.vpk file...

// HEADER
  4 - Header ((bytes)85, 170, 18, 52)
  4 - Version (2)
  4 - Directory Length
  4 - Internal File Data Length (in this file only)
  4 - External Checksum Directory Length
  4 - Internal Checksum Directory Length
  4 - Signature Directory Length

// DIRECTORY
  // for each file extension
    X - File Extension
    1 - null File Extension Terminator

    // for each directory within this File Extension
      X - Directory Name
      1 - null Directory Name Terminator

      // for each file in this Directory
        X - Filename
        1 - null Filename Terminator
        4 - CRC
        2 - Number of Preload Bytes (data in this file)
        2 - Number of Archive Package File (eg 2 == _002.vpk file) (or if the file data is in this directory file, the value = 32767)
        4 - File Offset (relative to the start of the Archive Package File referenced in the above field)
        4 - File Size (can be zero, if the bytes are all stored in Preload, and the whole file is contained in this directory file) (does not include the preload bytes length)
        2 - Entry Terminator (-1)

        if (PreloadBytes != 0){
          X - Preload Data
          }

      1 - null End Of Current "Directory" Terminator

    2 - null End Of Current "File Extension" Terminator

  // Repeat from "for each File Extension" whilever we haven't reached the Directory Length

// INTERNAL FILE DATA
  // for each file that contains internally-stored data
    X - File Data

// EXTERNAL CHECKSUM DIRECTORY
  // for each ??? (28 bytes per entry)
    4 - Number of Archive Package File
    4 - Start Offset
    4 - Number of Bytes to Check
    16 - Checksum

// INTERNAL CHECKSUM DIRECTORY
  16 - Checksum of the Directory
  16 - Checksum of the External Checksum Directory
  16 - Unknown

// SIGNATURE DIRECTORY
  4 - Public Key Size (160)
  X - Public Key
  4 - Signature Size (128)
  X - Signature

// FOOTER
  X - Extra CRC Data


These are the accompanying notes and further information:
 
Version 2 of the Valve Package Format

There is a file named _dir.vpk, which contains the directory for all package files with the name _###.vpk
The packages are numbered incrementally from 000.

If a file has preload data in it, it can be partially stored in the directory file in the preload section of the directory, or stored fully in there (if it's a small file).
To build the full file, you need preloadData + fileData


Game Extractor is able to read files of this type, as well as files from thousands of other games. To give it a try, download Game Extractor (Basic Version) for free, and see what it can do.

For further information on this format, refer to the source code on our GitHub repository.