From Valve Developer Community
Jump to: navigation, search

HLLib HLLib is a LGPL open source programming library, which abstracts several Half-Life and Half-Life 2 package formats and provides a simple interface for all of them. HLLib works natively in both Windows Windows and Linux Linux.

HLLib is written in native C++ but exposes both a C and C++ interface which can be used in any C or C++ application (additional languages may also use the library with Win32 imports).

Created by Ryan "Nemesis" Gregg.

File formats

  1. .bsp
  2. .gcf
  3. .ncf
  4. .pak
  5. .vpk[Clarify]
  6. .wad
  7. .xzp
  8. an uncompressed .zip[confirm][Clarify]


HLLib contains a example application called HLExtract. HLExtract is a GPL command-line utility written in C that can browse, extract, validate and defragment all supported packages. It provides a lean and mean shell-like interface for browsing as well as a command-line interface for automating tasks. HLExtract works natively in both Windows and Linux.



Common Options

-p <path>
Package file to open.
-d <path>
Directory to extract content to (defaults to the package's directory).
-e <path>
Path to a file for folder in the package to extract. Chain these for multiple items. -e root for everything.
-t <path>
Path to a file for folder in the package to validate. Chain these for multiple items. -t root for everything.
List the contents of the package. -ld for directories. -lf for files. -ldf for everything.
Defragment the package.
Drop into shell-like console mode.
Silent mode. Display minimal messages.
Use file mapping.
Use quick file mapping. (Must also specify -m.)
Allow volatile access. Enable this to share file access with other processes such as Steam.
Don't overwrite files when extracting.
Force complete lexicographical reordering of files during defragment even if there is no fragmentation.
-n <path>
The directory to find a NCF file's data in (for validation for example).
Note.pngNote:Dragging and dropping a package onto HLExtract.exe is equivalent to passing HLExtract.exe -p %1 -c -v



HLExtract.exe -p "half-life.gcf" -d "backup" -e "root\valve\models" -e "root\valve\config.cfg"
HLExtract.exe -p "half-life.gcf" -c -m -v
HLExtract.exe -p "half-life.gcf" -lf "half-life.txt"
HLExtract.exe -p "half-life.gcf" -m -f

Console Commands

List the current directory's contents.
cd <name>
Change directory to <name>. Type cd .. to go up one level.
info <name>
Display information about <name>.
extract <name>
Extract <name> to destination directory (specified by -d).
validate <name>
Validate <name> and its subdirectories.
find <string>
Search for <string> if the current directory and its subdirectories.
type <name>
Type the contents of <name> to the console.
open <name>
Open the package <name> within the current package.
Change to the root directory.
Display information about the package.
Clear the screen.
Display program help.
Exit the current package.

External links