- 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. |
||
|---|---|---|
| .gitignore | Implement blipks-pack spec parsing | |
| blipks-pack.cpp | Avoid leaking file handle on IO errors | |
| blipks-unpack.cpp | Fix file leaks | |
| blipks.hpp | First dirty working implementation of bipks-pack | |
| LICENSE | Add licence | |
| lzss-common.hpp | Correct header guards and filenames | |
| lzss.cpp | Avoid out-of-bounds access when skipping node | |
| lzss.hpp | Correct header guards and filenames | |
| Makefile | Remove unused phony target from Makefile | |
| readme.md | Fix typo in readme | |
| unlzss.cpp | Access optionals by reference | |
| unlzss.hpp | Correct header guards and filenames | |
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.ipkfile. Archives can be nested. - File lines of the format
[filename] [compressed].[compressed]may bento store the file uncompressed oryto compress it. - IPK end lines, which are exactly
ENDIPK.blipks-packwill 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.