WoWs depack
World of Warships resource files unpacker
|
Header file for the wows-depack library. More...
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
Functions | |
WOWS_CONTEXT * | wows_init_context (uint8_t debug_level) |
Initializes a WoWs resource extractor context. More... | |
int | wows_free_context (WOWS_CONTEXT *context) |
Frees a WoWs resource extractor context. More... | |
int | wows_free_context_no_munmap (WOWS_CONTEXT *context) |
Frees a WoW Stats Parser context without unmapping the memory. More... | |
int | wows_parse_index_file (const char *index_file_path, WOWS_CONTEXT *context) |
Parses a single WoWs resource index file. More... | |
int | wows_parse_index_dir (const char *index_dir_path, WOWS_CONTEXT *context) |
Parses all files in a given directory. More... | |
int | wows_parse_index_buffer (char *contents, size_t length, const char *index_file_path, int fd, WOWS_CONTEXT *context) |
Low level, parses a memory buffer directly. More... | |
int | wows_search (WOWS_CONTEXT *context, char *pattern, int mode, int *result_count, char ***results) |
Recursively searches for files in the WOWS archive tree that match a PCRE regular expression pattern. More... | |
int | wows_extract_file_fp (WOWS_CONTEXT *context, char *file_path, FILE *output) |
Extract a given file from the archive (file pointer version). More... | |
int | wows_extract_file (WOWS_CONTEXT *context, char *file_path, char *out_path) |
Extract a given file from the archive (output file version). More... | |
int | wows_extract_dir (WOWS_CONTEXT *context, char *dir_path, char *out_dir_path) |
Extract a given directory (recursively) from the archive (output file version). More... | |
int | wows_print_tree (WOWS_CONTEXT *context) |
Prints the directory tree of the given WoWs resource parser context in a tree format. More... | |
int | wows_print_flat (WOWS_CONTEXT *context) |
Prints the directory tree of the given WoWs resource parser context in a flat format. More... | |
char * | wows_error_string (int error_code, WOWS_CONTEXT *context) |
Converts an error code into an error message string for the given WoWs resource parser context. More... | |
int | wows_write_pkg (WOWS_CONTEXT *context, char *in_path, char *name, FILE *pkg_fp, FILE *idx_fp) |
Writes a package file and its index. More... | |
int | wows_get_latest_idx_dir (char *wows_base_dir, char **idx_dir) |
Gets the latest index directory in the specified WoWs installation directory. More... | |
Data Structures | |
struct | WOWS_CONTEXT |
Macros | |
#define | WOWS_ERROR_CORRUPTED_FILE 1 |
#define | WOWS_ERROR_BAD_MAGIC 2 |
#define | WOWS_ERROR_MISSING_METADATA_ENTRY 3 |
#define | WOWS_ERROR_MAX_LEVEL_REACHED 4 |
#define | WOWS_ERROR_NON_ZERO_TERMINATED_STRING 5 |
#define | WOWS_ERROR_PATH_TOO_LONG 6 |
#define | WOWS_ERROR_UNKNOWN 7 |
#define | WOWS_ERROR_ID_COLLISION_FILE_DIR 8 |
#define | WOWS_ERROR_FILE_OPEN_FAILURE 9 |
#define | WOWS_ERROR_DECOMPOSE_PATH 10 |
#define | WOWS_ERROR_INVALID_SEARCH_PATTERN 11 |
#define | WOWS_ERROR_NOT_A_FILE 12 |
#define | WOWS_ERROR_NOT_A_DIR 13 |
#define | WOWS_ERROR_NOT_FOUND 14 |
#define | WOWS_ERROR_FILE_WRITE 15 |
#define | WOWS_ERROR_MAX_FILE 16 |
#define | WOWS_NO_DEBUG 0 |
#define | WOWS_DEBUG_RAW_RECORD (1 << 0) |
#define | WOWS_DEBUG_FILE_LISTING (1 << 1) |
#define | WOWS_SEARCH_FILE_ONLY 0 |
#define | WOWS_SEARCH_DIR_ONLY 1 |
#define | WOWS_SEARCH_FILE_PLUS_DIR 2 |
#define | WOWS_SEARCH_FULL_PATH 3 |
Header file for the wows-depack library.
char* wows_error_string | ( | int | error_code, |
WOWS_CONTEXT * | context | ||
) |
Converts an error code into an error message string for the given WoWs resource parser context.
This function converts an error code into an error message string for the given WoWs resource parser context.
error_code | The error code to convert. |
context | A pointer to the WoWs resource parser context to use. |
int wows_extract_dir | ( | WOWS_CONTEXT * | context, |
char * | dir_path, | ||
char * | out_dir_path | ||
) |
Extract a given directory (recursively) from the archive (output file version).
This function will extract all files under the given directory. The whole directory tree from the archive will be recreated under out_dir_path.
context | Pointer to a WOWS_CONTEXT structure. |
dir_path | Path of the directory to extract. |
out_dir_path | Path to the output directory. |
int wows_extract_file | ( | WOWS_CONTEXT * | context, |
char * | file_path, | ||
char * | out_path | ||
) |
Extract a given file from the archive (output file version).
context | Pointer to a WOWS_CONTEXT structure. |
file_path | Path of the file to extract. |
out_path | Path to the output file. |
int wows_extract_file_fp | ( | WOWS_CONTEXT * | context, |
char * | file_path, | ||
FILE * | output | ||
) |
Extract a given file from the archive (file pointer version).
context | Pointer to a WOWS_CONTEXT structure. |
file_path | Path of the file to extract. |
output | Pointer to a FILE structure to write the output to. |
int wows_free_context | ( | WOWS_CONTEXT * | context | ) |
Frees a WoWs resource extractor context.
This function frees the memory allocated for a WoWs resource extractor context.
context | A pointer to the context to free. |
int wows_free_context_no_munmap | ( | WOWS_CONTEXT * | context | ) |
Frees a WoW Stats Parser context without unmapping the memory.
This function frees the memory allocated for a WoWs resource extractor context, but does not unmap the memory or close files from the process address space. This function should only be used if the raw wows_parse_index_buffer
function was used.
context | A pointer to the context to free. |
int wows_get_latest_idx_dir | ( | char * | wows_base_dir, |
char ** | idx_dir | ||
) |
Gets the latest index directory in the specified WoWs installation directory.
This function takes a base directory path for a World of Warships installation and a pointer to a char pointer to store the path of the latest index directory.
wows_base_dir | Path to the World of Warships installation directory. |
idx_dir | Pointer to a char pointer to store the name of the latest index directory. The memory for this pointer will be allocated by the function and must be freed by the caller. |
WOWS_CONTEXT* wows_init_context | ( | uint8_t | debug_level | ) |
Initializes a WoWs resource extractor context.
This function creates and initializes a new WoW Stats Parser context with the given debug level.
debug_level | The debug level for the parser. |
int wows_parse_index_buffer | ( | char * | contents, |
size_t | length, | ||
const char * | index_file_path, | ||
int | fd, | ||
WOWS_CONTEXT * | context | ||
) |
Low level, parses a memory buffer directly.
This function parses a WoWs resource index buffer directly from memory with the given contents and length, and updates the given parser context with the parsed data.
contents | A pointer to the buffer containing the WoWs resource index contents to parse. |
length | The length of the buffer in bytes. |
index_file_path | The path to the WoWs resource index file. |
fd | The file descriptor associated with the index file. |
context | A pointer to the parser context to update. |
int wows_parse_index_dir | ( | const char * | index_dir_path, |
WOWS_CONTEXT * | context | ||
) |
Parses all files in a given directory.
This function parses all WoWs resource index files in a given directory with the given path and updates the given parser context with the parsed data.
index_dir_path | The path to the directory containing the WoWs resource index files to parse. |
context | A pointer to the parser context to update. |
int wows_parse_index_file | ( | const char * | index_file_path, |
WOWS_CONTEXT * | context | ||
) |
Parses a single WoWs resource index file.
This function parses a single WoWs resource index file with the given path and updates the given parser context with the parsed data.
index_file_path | The path to the WoWs resource index file to parse. |
context | A pointer to the parser context to update. |
int wows_print_flat | ( | WOWS_CONTEXT * | context | ) |
Prints the directory tree of the given WoWs resource parser context in a flat format.
This function prints the directory tree of the given WoWs resource parser context in a flat format (each file with its full path).
For example: /dir1/file2 /dir3/dir4/file5
context | A pointer to the WoWs resource parser context to print. |
int wows_print_tree | ( | WOWS_CONTEXT * | context | ) |
Prints the directory tree of the given WoWs resource parser context in a tree format.
This function prints the directory tree of the given WoWs resource parser context in a tree format.
context | A pointer to the WoWs resource parser context to print. |
int wows_search | ( | WOWS_CONTEXT * | context, |
char * | pattern, | ||
int | mode, | ||
int * | result_count, | ||
char *** | results | ||
) |
Recursively searches for files in the WOWS archive tree that match a PCRE regular expression pattern.
context | The WOWS_CONTEXT object representing the root of the archive tree. | |
pattern | The PCRE regular expression pattern to match against file names. The pattern is passed to the matcher as ^{PATTERN}$ | |
mode | The search mode, which can be one of the following values:
| |
[out] | result_count | A pointer to an integer variable that will be set to the number of matching files or directories found. |
[out] | results | A pointer to an array of strings that will be allocated to hold the names of the matching files or directories. The caller is responsible for freeing the memory allocated for this array and its elements. |
This function searches recursively through the WOWS archive tree for files or directories that match the given PCRE regular expression pattern. The search can be restricted to files, directories, or the full path, depending on the value of the mode
parameter. The names of the matching files or directories are stored in the results
array, and the number of matches is stored in the result_count
variable. The caller is responsible for freeing the memory allocated for the results
array and its elements.
int wows_write_pkg | ( | WOWS_CONTEXT * | context, |
char * | in_path, | ||
char * | name, | ||
FILE * | pkg_fp, | ||
FILE * | idx_fp | ||
) |
Writes a package file and its index.
This function takes a WOWS_CONTEXT
pointer, an input directory path, a name for the .pkg file, and pointers to file streams for the package file and its index. The function writes the package file and its index to the provided file streams, using the given name.
context | Pointer to a WOWS_CONTEXT struct. |
in_path | Input directory path to package. |
name | Name for the '.pkg file'. |
pkg_fp | Pointer to a file stream to write the package file to. |
idx_fp | Pointer to a file stream to write the index file to. |
#define WOWS_DEBUG_FILE_LISTING (1 << 1) |
Debug output for file listings.
#define WOWS_DEBUG_RAW_RECORD (1 << 0) |
Debug output for raw records.
#define WOWS_ERROR_BAD_MAGIC 2 |
A bad magic number in a WoWs resource file.
#define WOWS_ERROR_CORRUPTED_FILE 1 |
A corrupted WoWs resource file.
#define WOWS_ERROR_DECOMPOSE_PATH 10 |
An error while decomposing a path.
#define WOWS_ERROR_FILE_OPEN_FAILURE 9 |
A failure to open a file.
#define WOWS_ERROR_FILE_WRITE 15 |
file write error
#define WOWS_ERROR_ID_COLLISION_FILE_DIR 8 |
A file and directory identifier collision.
#define WOWS_ERROR_INVALID_SEARCH_PATTERN 11 |
failure to compile regex pattern
#define WOWS_ERROR_MAX_FILE 16 |
maximum number of file/dir
#define WOWS_ERROR_MAX_LEVEL_REACHED 4 |
The maximum directory nesting level has been reached.
#define WOWS_ERROR_MISSING_METADATA_ENTRY 3 |
A missing metadata entry in a WoWs resource file.
#define WOWS_ERROR_NON_ZERO_TERMINATED_STRING 5 |
A non-zero-terminated string in a WoWs resource file.
#define WOWS_ERROR_NOT_A_DIR 13 |
path is not a directory
#define WOWS_ERROR_NOT_A_FILE 12 |
path is not a file
#define WOWS_ERROR_NOT_FOUND 14 |
file or directory not found
#define WOWS_ERROR_PATH_TOO_LONG 6 |
A path is too long to be processed.
#define WOWS_ERROR_UNKNOWN 7 |
An unknown error occurred.
#define WOWS_NO_DEBUG 0 |
No debug output.
#define WOWS_SEARCH_DIR_ONLY 1 |
Search only on directory names.
#define WOWS_SEARCH_FILE_ONLY 0 |
Search only on file names.
#define WOWS_SEARCH_FILE_PLUS_DIR 2 |
Search on directory and file names.
#define WOWS_SEARCH_FULL_PATH 3 |
Search on the full path of files.