Node bindings for CascLib
node-casclib has been tested on Windows and Linux. To install using npm
npm install casclib
or with yarn
yarn add casclib
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)
})
})
Possible game name values.
- Heroes of the Storm
- World of Warcraft
- Diablo 3
- Overwatch
- Starcraft
- Starcraft II
- Unknown
Supported locale values
- ALL
- NONE
- UNKNOWN1
- ENUS
- KOKR
- RESERVED
- FRFR
- DEDE
- ZHCN
- ESES
- ZHTW
- ENGB
- ENCN
- ENTW
- ESMX
- RURU
- PTBR
- ITIT
- PTPT
Object returned by getStorageInfo
fileCount
number of filesgameName
name of gamegameBuild
game build numberinstalledLocales
array of installed locale names
Callback signature used by openStorage
(error: Error, storageHandle: any) => void
Synchronously open CASC storage at path
openStorageSync(path: string, locales: string[] = [ 'ALL' ]): any
path
Path to location of CASC storagelocales
(defaults to[ 'ALL' ]
) Array ofstring
s of valid locales to open- returns a handle for the specified CASC storage
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): null
path
Path to location of CASC storagelocales
(defaults to[ 'ALL' ]
) Array ofstring
s of valid locales to opencallback
(optional) Called after CASC storage has been opened- returns
Promise
ifcallback
is not provided otherwise returnsnull
Get information about the opened CASC storage
getStorageInfo(storageHandle: any): StorageInfo
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
- returns a
StorageInfo
object
Close CASC storage
closeStorage(storageHandle: any): void
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
Object returned by findFiles
and findFilesSync
fullName
full path of filebaseName
file namefileSize
size of file
Synchronously search CASC storage for files that match the search pattern.
findFilesSync(storageHandle: any, searchPattern: string = "\*", listFilePath: string = ''): FindResult[]
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
searchPattern
(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
FindResult
s
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): null
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
searchPattern
(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
Promise
ifcallback
is not provided otherwise returnsnull
Callback signature used by openFile
.
(error: Error, fileHandle: any) => void
Callback signature used by read
and readFile
.
(error: Error, fileData: Buffer) => void
Synchronously open CASC file.
openFileSync(storageHandle: any, filePath: string)
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
filePath
CASC file path for file to open- returns handle for opened file
Asynchronously open CASC file.
openFile(storageHandle: any, filePath: string): Promise<any>
openFile(storageHandle: any, filePath: string, callback: OpenFileCallback): null
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
filePath
CASC file path for file to opencallback
(optional) called after file has been opened- returns
Promise
ifcallback
is not provided otherwise returnsnull
Synchronously read a file in CASC storage.
readSync(fileHandle: any): Buffer
fileHandle
handle for file to be read- returns
Buffer
with file contents
Asynchronously read a file in CASC storage.
read(fileHandle: any): Promise<Buffer>
read(fileHandle: any, callback: ReadFileCallback): null
fileHandle
handle for file to be read- returns
Promise
ifcallback
is not provided otherwise returnsnull
Synchronously read a file in CASC storage.
readFileSync(storageHandle: any, filePath: string): Buffer
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
filePath
CASC file path for file to open- returns
Buffer
with file contents
Asynchronously read a file in CASC storage.
readFile(storageHandle: any, filePath: string): Promise<Buffer>
readFile(storageHandle: any, filePath: string, callback: ReadFileCallback): null
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
filePath
CASC file path for file to readcallback
(optional) called after file has been opened and read- returns
Promise
ifcallback
is not provided otherwise returnsnull
Close CASC file
closeFile(fileHandle: any): void
storageHandle
handle returned by eitheropenStorageSync
oropenStorage
Readable Stream object used to read files in CASC storage.
path
path to the file in CASC storagestorageHandle
handle for CASC storagefileHandle
handle for CASC file. If providedpath
andstorageHandle
are not required.
Creates a FileReadable.
createReadStream(fileHandle: any, options?: ReadableOptions): Readable
createReadStream(storageHandle: any, filePath: string, options?: ReadableOptions): Readable
fileHandle
handle for file to be readstorageHandle
handle returned by eitheropenStorageSync
oropenStorage
filePath
-filePath
CASC file path for file to readoptions
(optional) stream options see nodejs stream docs for supported options.- returns a
FileReadable