NodeJS wrapper for StormLib
npm install stormlibbash
npm install
``
Build
``bash
node-gyp build
``
TODO
Support MacOSX, Linux
API
#### JStormLib.open
Open a MPQ archive, return a Promise.
``jsx
JStormLib.open(filepath).then(arcive => {
//archive.
}, err => {
console.log(err)
});
``
#### JStormLib.create
Create a new MPQ archive.
``jsx
JStormLib.create(filepath, flags, maxFileCount).then(arcive => {
//archive.
}, err => {
console.log(err)
});
``
|Name|Type|Description|
|----|----|-----------|
|filepath|string|Archive file name
|flags|int|Additional flags to specify creation details. see CreateArchiveFlags
|maxFileCount|int|Limit for file count
##### CreateArchiveFlags
Specifies additional flags for MPQ creation process. This parameter can be combination of the following flags:
|Value|Description|
|-----|-----------|
|0x00100000|The newly created archive will have (listfile) present.|
|0x00200000|The newly created archive will have additional attributes in (attributes) file.|
|0x00400000|The newly created archive will be signed with weak digital signature (the "(signature) file).|
|0x00000000|The function creates a MPQ version 1.0 (up to 4 GB). This is the default value|
|0x01000000|The function creates a MPQ version 2.0 (supports MPQ of size greater than 4 GB).|
|0x02000000|The function creates a MPQ version 3.0 (introduced in WoW-Cataclysm Beta).|
|0x03000000|The function creates a MPQ version 4.0 (used in WoW-Cataclysm).|
#### StormArchive.getLocale
``js
JStormLib.open(filepath).then(arcive => {
archive.getLocale();
}, err => {
console.log(err)
});
``
Returns current locale ID for adding new files
#### StormArchive.setLocale
``js
archive.setLocale(lcid);
``
Changes default locale ID for adding new files
what is LCID?
#### StormArchive.getFileList
``js
archive.getFileList();
// ['a.txt', 'b.txt]
``
get a list of all files in the current archive
#### StormArchive.readFile
``
archive.readFile(filename).then(fileBuffer => {
//save the buffer;
}, err => {
console.log(err);
})
``
read file data by the specified file name.
#### StormArchive.writeFile
``
archive.writeFile(buffer, filename, lcid, flags, compression).then(fileBuffer => {
//save the buffer;
}, err => {
console.log(err);
})
``
writes data to the archive.
|Name|Type|Description|
|----|----|-----------|
|buffer|Buffer| data to be written|
|filename|string| file name|
|lcid|int|language Code Identifier|
|flags|int|See WriteFileFlags |
|compression|int|See Compression
##### WriteFileFlags
Specifies additional options about how to add the file to the MPQ. The value of this parameter can be a combination of the following values:
__StarCraft1 Map(.scx, .scm) use 0x00010200__
|Value|Description|
|-----|-----------|
|0x00000100|The file will be compressed using IMPLODE compression method.
|0x00000200|The file will be compressed
|0x00010000|The file will be stored as encrypted.
|0x00020000|The file's encryption key will be adjusted according to file size in the archive.
|0x02000000|The file will have the deletion marker.
|0x04000000|The file will have CRC for each file sector. Ignored if the file is not compressed or if the file is stored as single unit.
|0x01000000|The file will be added as single unit. Files stored as single unit cannot be encrypted, because Blizzard doesn't support them.
|0x80000000|If this flag is specified and the file is already in the MPQ, it will be replaced.
##### WriteFileCompression
Compression method of the first file block. This parameter is ignored if MPQ_FILE_COMPRESS is not specified in dwFlags. This parameter can be a combination of the following values:
__StarCraft1 Map(.scx, .scm) use 0x08`__