#archive #file-format #gamedev #library #gob #lucasarts

gob_rs

Library for parsing and constructing archives of the LucasArts GOB format

4 stable releases

1.3.0 Apr 12, 2024
1.2.1 Apr 10, 2024
1.2.0 Apr 6, 2024
1.1.0 Apr 6, 2024
1.0.0 Apr 5, 2024

#1076 in Parser implementations

Download history 27/week @ 2024-09-23

243 downloads per month
Used in gob_archive

MIT/Apache

15KB
160 lines

gob-rs

A Rust library for parsing, constructing, and generating archives of the LucasArts GOB format.

This implementation has been tested to work with GOB files of:

  • Indiana Jones and the Infernal Machine
  • Star Wars Jedi Knight: Dark Forces II

For a GOB archiver/unarchiver using this library, see gob-archive.

Examples

Parsing GOB File

use std::path::Path;
use gob_rs::core::Gob;

fn main() -> std::io::Result<()> {
    let gob = Gob::from_file(Path::new("/path/to/gob.GOB"))?;

    Ok(())
}

Parsing GOB-Like* Directory

*That is, a directory structured like a GOB archive.

use std::path::Path;
use gob_rs::core::Gob;

fn main() -> std::io::Result<()> {
    let gob = Gob::from_directory(Path::new("/path/to/gob"))?;

    Ok(())
}

Generating GOB file data

use std::path::PathBuf;
use gob_rs::core::Gob;

let mut gob = Gob::new();

gob.files.insert(
    PathBuf::from("foo.bar"),
    b"foobar".to_vec(),
);

gob.files.insert(
    PathBuf::from("fizz.buzz"),
    b"fizzbuzz".to_vec(),
);

let data = gob.as_bytes();

Specification

GOB files are used by LucasArts games built on the Sith engine as an archive format for storing game files.

They are encoded in the little-endian format.

The file structure can be abstracted as follows:

Gob {
    header: Header,
    body: Body,
}

Header {
    signature: 4 bytes, // must be "GOB "
    version: 4 bytes, // must be 0x14 -> 20
    body_offset: 4 bytes, // usually 0xC -> 12; byte address where body starts
}

Body {
    file_count: 4 bytes, // amount of files in archive
    files: [File; file_count], // file definitions
    ...file_data, // data of files; makes up remainder, thus size is variable
}

File {
    offset: 4 bytes, // byte address where file data starts
    size: 4 bytes, // size of file data in bytes
    filepath: 128 bytes, // path of file within archive; null-terminated, may contain garbage data past terminator
}

Limitations

One major limitation that arises due to the strict memory definitions of the file format is that the relative paths of files within a GOB archive may at most be 128 ASCII characters (or 128 bytes) long.

Another limitation is that due to the 32-Bit architecture of the format, GOB archives can at most reach a size of about 4 GB before breaking due to being unable to reference data offset past the 32-Bit limit.

License

This library is dual-licensed under the MIT license and Apache License, Version 2.0.

No runtime deps