bw-casclib v2.0.2
bw-casclib
Node bindings for CascLib
Note this is a fork to support the latest version of CascLib as node-casclib has been abandoned. Only StarCraft is supported.
Installation
bw-casclib has been tested on Windows and Linux. To install using npm
npm install bw-casclibor with yarn
yarn add bw-casclibUsage
Reading a file synchronously.
import * as casclib from 'casclib'
const storageHandle = casclib.openStorageSync("path/to/game/directory")
const fileData = casclib.readFile("path/to/casc/file")
casclib.closeStorage(storageHandle)Read a file asynchronously with promises.
import * as casclib from 'casclib'
casclib.openStorage("path/to/game/directory")
.then(storageHandle => {
return casclib.readfile("path/to/casc/file")
.then(fileData => {
// do things with file data
casclibe.closeStorage(storageHandle)
})
})Read a file asynchronously with callbacks.
import * as casclib from 'casclib'
casclib.openStorage("path/to/game/directory", (error, storageHandle) => {
if(error) {
// handle error
}
casclib.readFile("path/to/casc/file", (error, fileData) => {
if(error) {
// handle error
}
// do things with file data
casclib.closeStorage(storageHandle)
})
})API
CASC Storage and storage info
Game Names
Possible game name values.
- Heroes of the Storm
- World of Warcraft
- Diablo 3
- Overwatch
- Starcraft
- Starcraft II
- Unknown
Locales
Supported locale values
- ALL
- NONE
- UNKNOWN1
- ENUS
- KOKR
- RESERVED
- FRFR
- DEDE
- ZHCN
- ESES
- ZHTW
- ENGB
- ENCN
- ENTW
- ESMX
- RURU
- PTBR
- ITIT
- PTPT
StorageInfo
Object returned by getStorageInfo
fileCountnumber of filesgameNamename of gamegameBuildgame build numberinstalledLocalesarray of installed locale names
OpenStorageCallback
Callback signature used by openStorage
(error: Error, storageHandle: any) => voidopenStorageSync
Synchronously open CASC storage at path
openStorageSync(path: string, locales: string[] = [ 'ALL' ]): anypathPath to location of CASC storagelocales(defaults to[ 'ALL' ]) Array ofstrings of valid locales to open- returns a handle for the specified CASC storage
openStorage
Asynchronously open CASC storage for path and locales
openStorage(path: string): Promise<any>
openStorage(path: string, locales: string[]): Promise<any>
openStorage(path: string, callback: OpenStorageCallback): null
openStorage(path: string, locales: string[], callback: OpenStorageCallback): nullpathPath to location of CASC storagelocales(defaults to[ 'ALL' ]) Array ofstrings of valid locales to opencallback(optional) Called after CASC storage has been opened- returns
Promiseifcallbackis not provided otherwise returnsnull
getStorageInfo
Get information about the opened CASC storage
getStorageInfo(storageHandle: any): StorageInfostorageHandlehandle returned by eitheropenStorageSyncoropenStorage- returns a
StorageInfoobject
closeStorage
Close CASC storage
closeStorage(storageHandle: any): voidstorageHandlehandle returned by eitheropenStorageSyncoropenStorage
Find files
FindResult
Object returned by findFiles and findFilesSync
fullNamefull path of filebaseNamefile namefileSizesize of file
findFilesSync
Synchronously search CASC storage for files that match the search pattern.
findFilesSync(storageHandle: any, searchPattern: string = "\*", listFilePath: string = ''): FindResult[]storageHandlehandle returned by eitheropenStorageSyncoropenStoragesearchPattern(defaults to "*") Can use*to match any number of characters in the file path or?to match a single character.listFilePath(defaults to an empty string) path to file containing list of files in the CASC storage (only required for WOW)- returns list of
FindResults
findFiles
Asynchronously search CASC storage for files that match the search pattern.
findFiles(storageHandle: any, searchPattern: string): Promise<FindResult[]>
findFiles(storageHandle: any, searchPattern: string, listFilePath: string): Promise<FindResult[]>
findFiles(storageHandle: any, searchpattern: string, callback: FindFilesCallback): nullstorageHandlehandle returned by eitheropenStorageSyncoropenStoragesearchPattern(defaults to "*") Can use*to match any number of characters in the file path or?to match a single character.listFilePath(defaults to an empty string) path to file containing list of files in the CASC storage (only required for WOW)- returns
Promiseifcallbackis not provided otherwise returnsnull
Open and Read files in CASC storage
OpenFileCallback
Callback signature used by openFile.
(error: Error, fileHandle: any) => voidReadFileCallback
Callback signature used by read and readFile.
(error: Error, fileData: Buffer) => voidopenFileSync
Synchronously open CASC file.
openFileSync(storageHandle: any, filePath: string)storageHandlehandle returned by eitheropenStorageSyncoropenStoragefilePathCASC file path for file to open- returns handle for opened file
openFile
Asynchronously open CASC file.
openFile(storageHandle: any, filePath: string): Promise<any>
openFile(storageHandle: any, filePath: string, callback: OpenFileCallback): nullstorageHandlehandle returned by eitheropenStorageSyncoropenStoragefilePathCASC file path for file to opencallback(optional) called after file has been opened- returns
Promiseifcallbackis not provided otherwise returnsnull
readSync
Synchronously read a file in CASC storage.
readSync(fileHandle: any): BufferfileHandlehandle for file to be read- returns
Bufferwith file contents
read
Asynchronously read a file in CASC storage.
read(fileHandle: any): Promise<Buffer>
read(fileHandle: any, callback: ReadFileCallback): nullfileHandlehandle for file to be read- returns
Promiseifcallbackis not provided otherwise returnsnull
readFileSync
Synchronously read a file in CASC storage.
readFileSync(storageHandle: any, filePath: string): BufferstorageHandlehandle returned by eitheropenStorageSyncoropenStoragefilePathCASC file path for file to open- returns
Bufferwith file contents
readFile
Asynchronously read a file in CASC storage.
readFile(storageHandle: any, filePath: string): Promise<Buffer>
readFile(storageHandle: any, filePath: string, callback: ReadFileCallback): nullstorageHandlehandle returned by eitheropenStorageSyncoropenStoragefilePathCASC file path for file to readcallback(optional) called after file has been opened and read- returns
Promiseifcallbackis not provided otherwise returnsnull
closeFile
Close CASC file
closeFile(fileHandle: any): voidstorageHandlehandle returned by eitheropenStorageSyncoropenStorage
FileReadable
Readable Stream object used to read files in CASC storage.
pathpath to the file in CASC storagestorageHandlehandle for CASC storagefileHandlehandle for CASC file. If providedpathandstorageHandleare not required.
createReadStream
Creates a FileReadable.
createReadStream(fileHandle: any, options?: ReadableOptions): Readable
createReadStream(storageHandle: any, filePath: string, options?: ReadableOptions): ReadablefileHandlehandle for file to be readstorageHandlehandle returned by eitheropenStorageSyncoropenStoragefilePath-filePathCASC file path for file to readoptions(optional) stream options see nodejs stream docs for supported options.- returns a
FileReadable