1
2
Fork
You've already forked blipks
0
BLiNX 2 .ipk unpacker and re-packer
  • C++ 99%
  • Makefile 1%
KeybadeBlox 8a0d684871 Fix file leaks
GCC appears to have been correct I was leaking a file, but I have to
admit its way of communicating such (saying that a call to fputs() was
the line it was getting leaked on?) was so obtuse that I couldn't figure
out what it was saying.
Thank you Valgrind for communicating more clearly.
2024年05月21日 23:10:53 -04:00
.gitignore Implement blipks-pack spec parsing 2024年04月27日 20:51:55 -04:00
blipks-pack.cpp Avoid leaking file handle on IO errors 2024年05月20日 21:13:53 -04:00
blipks-unpack.cpp Fix file leaks 2024年05月21日 23:10:53 -04:00
blipks.hpp First dirty working implementation of bipks-pack 2024年05月08日 20:41:54 -04:00
LICENSE Add licence 2024年04月19日 21:23:09 -04:00
lzss-common.hpp Correct header guards and filenames 2024年05月05日 14:54:36 -04:00
lzss.cpp Avoid out-of-bounds access when skipping node 2024年05月20日 20:38:01 -04:00
lzss.hpp Correct header guards and filenames 2024年05月05日 14:54:36 -04:00
Makefile Remove unused phony target from Makefile 2024年05月19日 23:22:27 -04:00
readme.md Fix typo in readme 2024年05月20日 21:26:00 -04:00
unlzss.cpp Access optionals by reference 2024年04月27日 11:11:19 -04:00
unlzss.hpp Correct header guards and filenames 2024年05月05日 14:54:36 -04:00

blipks

blipks comprises two tools, blipks-unpack and blipks-pack, for extracting files from BLiNX 2 .ipk archives and creating new archives, respectively. These tools aim to be round-trippable, i.e. unpacking the original BLiNX 2 .ipk files via blipks-unpack and re-packing them via blipks-pack should reproduce the original files exactly.

Installation

64-bit Linux and Windows can use the latest binaries from the releases.

Otherwise, the only dependency for compilation is a C++17 compiler. A Makefile is provided for systems supporting it, else source files can be compiled directly.

Usage

blipks-unpack

Two arguments are required: the path of the .ipk file to extract and the path to write a specification of the provided .ipk to:

$ blipks-unpack path/to/archive.ipk output/path/to/spec.txt

The archive files are extracted to the current directory. The resulting specification can be provided to blipks-pack to produce a new .ipk archive with the same structure.

blipks-pack

One argument is required: the path of a specification file, such as that produced by blipks-unpack:

$ blipks-pack path/to/spec.txt

The .ipk file described by the specification file will be built using files in the current working directory.

Specification Format

blips-pack requires a specification file as input. Normally, one would produce the file via blipks-unpack and use it to create a similar .ipk file, which requires no knowledge of the specification file format. Nevertheless, the format is as follows.

Specification files use a line-oriented format with three line types:

  • IPK start lines of the format IPK [filename] [alignment] [filecount]. The first line must be of this type. Everything between this line and the matching IPK end line will be copied into this .ipk file. Archives can be nested.
  • File lines of the format [filename] [compressed]. [compressed] may be n to store the file uncompressed or y to compress it.
  • IPK end lines, which are exactly ENDIPK. blipks-pack will stop reading the specification file once it reaches the IPK end line matching the first IPK start line.

The formats given above are whitespace-sensitive, i.e. exactly one space must be included between each field. Filenames must not contain spaces.

Overview of .ipk Files

The BLiNX 2 .ipk format behaves and is used slightly differently than traditional archive formats like .tar or .zip. Each archived file is given an absolute filepath*, to which the game can extract the file at runtime. Many .ipk files also contain .ipk files within them, and these nested archives can contain duplicates of files in the parent archive. Structures like the below are thus possible:

- parent.ipk
 - dir1\file1.ext
 - dir2\file2.ext
 - dir1\child.ipk
 - dir1\file1.ext
 - dir1\file3.ext

In the example above, parent.ipk and dir1\child.ipk both contain copies of dir1\file1.ext. Unpacking parent.ipk via blipks would produce the following structure:

- dir1\
 - file1.ext
 - file3.ext
- dir2\
 - file2.ext

As blipks always extracts .ipk archives recursively, dir1\child.ipk was extracted as part of extracting parent.ipk, so it does not appear in the output and the directory it's indicated to reside in has no effect. At runtime, however, BLiNX 2 may extract individual .ipk files into their specified locations on the hard drive.

*There is for some reason a lone exception to this, media.ipk, whose top-level contents are extracted into Z:\media instead of the partition root Z:\. blipks special-cases archives named media.ipk to handle this.