From 73f37fa271d00d024b018a19ed96e201a725e33a Mon Sep 17 00:00:00 2001 From: Waddlesworth Date: Fri, 15 Feb 2019 14:10:12 +1100 Subject: [PATCH] added pak key function --- native/Cargo.lock | 10 +++++----- native/Cargo.toml | 2 +- native/src/lib.rs | 11 +++++++++++ package.json | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/native/Cargo.lock b/native/Cargo.lock index 5e4dc0b..c3da8bb 100644 --- a/native/Cargo.lock +++ b/native/Cargo.lock @@ -194,8 +194,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "john-wick-parse" -version = "0.4.1" -source = "git+https://github.com/SirWaddles/JohnWickParse#a19d5ed068a34173827c9bee2e90c71412dd9b52" +version = "0.5.0" +source = "git+https://github.com/SirWaddles/JohnWickParse#bf6c37483b3bab56bb587481fc3f75c4af92f4d2" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -279,9 +279,9 @@ dependencies = [ [[package]] name = "node-wick" -version = "0.3.1" +version = "0.4.0" dependencies = [ - "john-wick-parse 0.4.1 (git+https://github.com/SirWaddles/JohnWickParse)", + "john-wick-parse 0.5.0 (git+https://github.com/SirWaddles/JohnWickParse)", "neon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "neon-build 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "neon-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -562,7 +562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum image 0.21.0 (git+https://github.com/SirWaddles/image)" = "" "checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum john-wick-parse 0.4.1 (git+https://github.com/SirWaddles/JohnWickParse)" = "" +"checksum john-wick-parse 0.5.0 (git+https://github.com/SirWaddles/JohnWickParse)" = "" "checksum jpeg-decoder 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b7d43206b34b3f94ea9445174bda196e772049b9bddbc620c9d29b2d20110d" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" "checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" diff --git a/native/Cargo.toml b/native/Cargo.toml index 66bb68d..e95e0af 100644 --- a/native/Cargo.toml +++ b/native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-wick" -version = "0.3.1" +version = "0.4.0" authors = ["Waddlesworth "] license = "MIT" build = "build.rs" diff --git a/native/src/lib.rs b/native/src/lib.rs index d893c0a..0d78f8f 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -67,6 +67,16 @@ fn read_texture_to_file(mut cx: FunctionContext) -> JsResult { Ok(JsBoolean::new(&mut cx, true).upcast()) } +fn read_pak_key(mut cx: FunctionContext) -> JsResult { + let asset_path = cx.argument::(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) { @@ -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::("PakExtractor")?; Ok(()) }); diff --git a/package.json b/package.json index 0e1ab57..93374c3 100644 --- a/package.json +++ b/package.json @@ -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": {