Skip to content

Commit

Permalink
added pak key function
Browse files Browse the repository at this point in the history
  • Loading branch information
SirWaddles committed Feb 15, 2019
1 parent 30cdc55 commit 73f37fa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
10 changes: 5 additions & 5 deletions native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "node-wick"
version = "0.3.1"
version = "0.4.0"
authors = ["Waddlesworth <[email protected]>"]
license = "MIT"
build = "build.rs"
Expand Down
11 changes: 11 additions & 0 deletions native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ fn read_texture_to_file(mut cx: FunctionContext) -> JsResult<JsValue> {
Ok(JsBoolean::new(&mut cx, true).upcast())
}

fn read_pak_key(mut cx: FunctionContext) -> JsResult<JsString> {
let asset_path = cx.argument::<JsString>(0)?.value();
let header = match PakExtractor::new_header(&asset_path) {
Ok(data) => data,
Err(err) => return cx.throw_error(parse_err(err)),
};

Ok(JsString::new(&mut cx, header.get_key_guid().to_string()))
}

declare_types! {
pub class JsPakExtractor for PakExtractor {
init(mut cx) {
Expand Down Expand Up @@ -123,6 +133,7 @@ register_module!(mut cx, {
cx.export_function("read_asset", read_asset)?;
cx.export_function("read_texture", read_texture)?;
cx.export_function("read_texture_to_file", read_texture_to_file)?;
cx.export_function("read_pak_key", read_pak_key)?;
cx.export_class::<JsPakExtractor>("PakExtractor")?;
Ok(())
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-wick",
"version": "0.3.1",
"version": "0.4.0",
"description": "NodeJS Bindings for the JohnWickParse library",
"main": "lib/index.js",
"repository": {
Expand Down

0 comments on commit 73f37fa

Please sign in to comment.