Skip to content

Commit 24610cc

Browse files
committed
Merge pull request #2 from TeskeVirtualSystem/JPKExt
Jpk ext
2 parents 46ea282 + af1ca2b commit 24610cc

11 files changed

Lines changed: 571 additions & 7 deletions

File tree

doc/JPAK2/Extended Mode/README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The JPAK Meta Storage is similar to JPAK Filetable Structure, but aditionally ha
3131
| ------------ | ------------- | ------------------------------------------------- |
3232
| 0x0 | 0x4 | JMS1 Magic Number |
3333
| 0x4 | 0xC | Padding (0x00) |
34-
| 0x**V** | 0x**U** | JSON Volume Table |
34+
| 0xC | 0x**U** | JSON Volume Table |
3535
| 0x**U** | 0x**W** | JSON File Table |
3636
| 0x**X** | 0x**X+4** | `uint32_t` Producer ID (Look JPAK2.0 spec at 2.1) |
3737
| 0x**X+4** | 0x**X+8** | `uint32_t` JPAK Flags (Look JPAK2.0 spec at 2.1) |
@@ -41,15 +41,11 @@ The JPAK Meta Storage is similar to JPAK Filetable Structure, but aditionally ha
4141
The JSON Filetable is the same, the offset is relative to the first volume. The JSON Volume Table is as follow:
4242

4343
{
44-
"0" : {
44+
"vol0.jds" : {
4545
"filename" : "vol0.jds", // Volume Filename
46-
"start" : "0", // Start of volume in Bytes
47-
"end" : "1024", // End of volume in Bytes
4846
},
49-
"1" : {
47+
"vol1.jds" : {
5048
"filename" : "vol1.jds", // Volume Filename
51-
"start" : "1024", // Start of volume in Bytes
52-
"end" : "4096", // End of volume in Bytes
5349
}
5450
}
5551

doc/JPAK2/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ And for the file entries:
3131
"size" : FILESIZE // The file size
3232
"aeskey" : AESKEY // File key if != false
3333
"zlib" : FALSE/TRUE // If file is compressed
34+
"volume" : VOLUMEID // ID from VolumeTable
3435
"md5" : MD5SUM // Uncompresssed/unencrypted file MD5SUM
3536
}
3637

@@ -47,11 +48,13 @@ Example of JPAK Filesystem Table:
4748
'path': '/whatisthis',
4849
'offset': 13,
4950
'name': 'whatisthis',
51+
'volume': 'vol0.jdt',
5052
'size': 55
5153
},
5254
'test.html': {
5355
'path': '/test.html',
5456
'offset': 81,
57+
'volume': 'vol1.jdt',
5558
'name': 'test.html',
5659
'size': 49
5760
},
@@ -66,6 +69,7 @@ Example of JPAK Filesystem Table:
6669
't': {
6770
'path': '/3/t',
6871
'offset': 9104,
72+
'volume': 'vol0.jdt',
6973
'name': 't',
7074
'size': 0
7175
}

js/jpak.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ JPAK.jpakloader.prototype.Load = function() {
217217
if (this.status === 200) {
218218
var data = this.response;
219219
var MagicNumber = u8as(new Uint8Array(data.slice(0,5)));
220+
var MagicNumber2 = u8as(new Uint8Array(data.slice(0,4)));
220221
if(MagicNumber === "JPAK1") {
221222
JPAK.log("JPAK::jpakloader - Loaded file "+_this.jpakfile+" successfully. JPAK1 Format");
222223
var filetableoffset = new DataView(data.slice(data.byteLength-4,data.byteLength)).getUint32(0, true);
@@ -227,6 +228,10 @@ JPAK.jpakloader.prototype.Load = function() {
227228
_this.dataloaded = true;
228229
if(_this.onload !== undefined)
229230
_this.onload();
231+
} else if(MagicNumber === "JMS1") {
232+
JPAK.log("JPAK::jpakloader - Loaded JPAK Metadata File "+_this.jpakfile+" successfully.");
233+
} else if(MagicNumber2 === "JDS1") {
234+
JPAK.log("JPAK::jpakloader - Loaded JPAK Storage File "+_this.jpakfile+" successfully.");
230235
}else{
231236
JPAK.log("JPAK::jpakloader - Error loading file "+_this.jpakfile+" (8000): Wrong File Magic. Expected JPAK1 got "+MagicNumber);
232237
if(_this.onerror !== undefined)

tools/extpacker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var fs = require("fs");

tools/extpacker.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python
2+
3+
print '''
4+
_ ____ _ _ __ _____ _ ____ _
5+
| | _ \ / \ | |/ / | ____|_ _| |_ | _ \ __ _ ___| | _____ _ __
6+
_ | | |_) / _ \ | ' / | _| \ \/ / __| | |_) / _` |/ __| |/ / _ \ '__|
7+
| |_| | __/ ___ \| . \ | |___ > <| |_ | __/ (_| | (__| < __/ |
8+
\___/|_| /_/ \_\_|\_\ |_____/_/\_\\__| |_| \__,_|\___|_|\_\___|_|
9+
10+
Multiuse Javascript Package
11+
By: Lucas Teske
12+
https://github.com/racerxdl/jpak
13+
'''
14+
15+
16+
import struct, os, json, sys
17+
from jpaktool import *
18+
from jpakmodels import *
19+
20+
if len(sys.argv) > 3:
21+
metadataF = sys.argv[1]
22+
volume = sys.argv[2]
23+
user_args = sys.argv[3:]
24+
metadata = JMS()
25+
if os.path.isfile(metadataF):
26+
print "Metadata %s has been found. Appending volume %s to JPAK" %(metadata, volume)
27+
f = open(metadataF, "rb")
28+
data = f.read()
29+
f.close()
30+
metadata.fromBinary(data)
31+
32+
jdata = JDS(os.path.basename(volume), volume)
33+
metadata.addVolume(jdata)
34+
35+
for ua in user_args:
36+
metadata.fromDirectory(ua, jdata)
37+
38+
metadata.toFile(metadataF)
39+
40+
else:
41+
print '''
42+
Usage: python packer.py metadata.jms volumeX.jds folder ...
43+
Ex: python extpacker.py myproject.jms volume0.jds /home/lucas/
44+
This will generate myproject.jms (or append a new volume) with contents of folder /home/lucas'''

0 commit comments

Comments
 (0)