4个稳定版本
1.3.0 | 2024年4月12日 |
---|---|
1.2.1 | 2024年4月10日 |
1.2.0 | 2024年4月6日 |
1.1.0 | 2024年4月6日 |
1.0.0 |
|
在 解析器实现 中排名第 957
每月下载量243次
在 gob_archive 中使用
15KB
160 行
gob-rs
一个用于解析、构建和生成LucasArts GOB格式存档的Rust库。
此实现经过测试,可以与以下GOB文件兼容:
- 《印第安纳琼斯与地狱机械师》
- 《星球大战:绝地武士骑士:黑暗力量II》
有关使用此库的GOB存档/解存档器,请参阅 gob-archive。
示例
解析GOB文件
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(())
}
解析类似GOB的目录
*即,类似于GOB存档的目录结构。
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(())
}
生成GOB文件数据
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();
规范
GOB文件由建立在Sith引擎上的LucasArts游戏使用,作为存储游戏文件的存档格式。
它们以小端格式编码。
文件结构可以抽象如下
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
}
限制
由于文件格式严格的内存定义而产生的一个主要限制是,GOB存档内文件的相对路径最多只能是128个ASCII字符(或128个字节)长。
另一个限制是,由于格式的32位架构,GOB存档在超过32位限制而无法引用数据偏移后可能会达到大约4GB的大小,从而损坏。
许可证
此库以MIT许可证和Apache许可证2.0双授权。