Code Monkey home page Code Monkey logo

gob-rs's Introduction

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.

gob-rs's People

Contributors

cubesandcubes avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.