17#ifndef H_T2FS_TUROK2_FILESYSTEM
18#define H_T2FS_TUROK2_FILESYSTEM
38#define T2FS_NODE_SANE_MAX_COUNT 65000
39#define T2FS_NODE_SANE_MIN_OFFSET 0x10
41#define T2FS_PRINT_ERROR_NODE(node, ...) t2fs_print_error_node(T2FS_PRINT_FLAG_ERROR, __func__, node, __VA_ARGS__)
42#define T2FS_PRINT_WARN_NODE(node, ...) t2fs_print_error_node(T2FS_PRINT_FLAG_WARNING, __func__, node, __VA_ARGS__)
43#define T2FS_PRINT_DEBUG_NODE(node, ...) t2fs_print_error_node(T2FS_PRINT_FLAG_DEBUG, __func__, node, __VA_ARGS__)
253#define NODE_MAX_LEVEL 64
254#define NODE_PATH_END (uint32_t)-1
342 const char *
const filepath,
343 const char *
const schemaPath,
344 uint8_t searchSchema);
struct s_T2FSFileConfig T2FSFileConfig
struct s_T2FSSchemaNode T2FSSchemaNode
Definition schema.h:29
This is the core LibT2FS object that you will be passing around.
Definition t2fs.h:289
T2FSNode * models
Definition t2fs.h:311
T2FSNode * levels
Definition t2fs.h:313
T2FSFileConfig config
We might need different config for different files, these configs are pre-defined and contain info li...
Definition t2fs.h:296
T2FSNode * textures
Definition t2fs.h:312
T2FSNode * scenes
Definition t2fs.h:315
T2FSNode * spawnpoints
Definition t2fs.h:314
t_rnc rnc
RNC decompression context.
Definition t2fs.h:308
T2FSInput input
File input reading.
Definition t2fs.h:300
T2FSNode root
Root node.
Definition t2fs.h:304
uint32_t count
Definition t2fs.h:257
uint32_t segs[NODE_MAX_LEVEL]
Definition t2fs.h:256
This is the core object to describe a path inside the tree.
Definition t2fs.h:114
uint8_t * data
Data of this node, can be another offset table (branch node) or data (data/leaf node) depending on sc...
Definition t2fs.h:147
T2FSNode * childNodes
Pointer to the child node(s).
Definition t2fs.h:172
T2FSNode * parent
The parent node.
Definition t2fs.h:161
uint32_t size
Data size of this node.
Definition t2fs.h:136
T2FSSchemaNode * schema
Definition t2fs.h:115
uint32_t offset
Offset to this node.
Definition t2fs.h:128
uint8_t isCompressed
Indicator that the data is compressed.
Definition t2fs.h:176
T2FSContext * ctx
Pointer to our context for convenience.
Definition t2fs.h:184
uint8_t hasBeenRead
Indicator that the data for this node has been read.
Definition t2fs.h:180
T2FSInput * input
For reading data.
Definition t2fs.h:155
uint32_t childCount
How many child nodes this node has.
Definition t2fs.h:166
uint32_t id
Index of this node.
Definition t2fs.h:119
enum e_t2fsReadSize t2fsReadSize
To handle swapping endianness.
struct s_T2FSNode T2FSNode
This is the core object to describe a path inside the tree.
Definition t2fs.h:110
void t2fs_print_error_node(int printType, const char *const func, T2FSNode *node, const char *const fmt,...)
int t2fs_node_guess_read_recursive(T2FSContext *ctx, T2FSNode *node, uint8_t loadData, uint8_t decompress)
void t2fs_node_print_recursive(const T2FSNode *const node, uint32_t indent)
e_t2fsReadSize
To handle swapping endianness.
Definition t2fs.h:47
@ T2FS_READ_16
Definition t2fs.h:48
@ T2FS_READ_32
Definition t2fs.h:49
#define NODE_MAX_LEVEL
Definition t2fs.h:253
void t2fs_node_path_parse(T2FSNodePath *np, T2FSNode *node)
uint8_t t2fs_node_has_index(const T2FSNode *const node, uint32_t index)
Check if the node has a child node with the given index.
void t2fs_node_free_childeren(T2FSNode *node)
This should be called after successfully call to t2fs_node_read_branch().
void t2fs_node_init(T2FSNode *node)
void t2fs_node_path_init(T2FSNodePath *np)
void t2fs_node_path_print(const T2FSContext *const ctx, const T2FSNodePath *const np)
int t2fs_node_read_data(T2FSContext *ctx, T2FSNode *node)
Read node data.
T2FSStatus t2fs_open(T2FSContext *ctx, const char *const filepath, const char *const schemaPath, uint8_t searchSchema)
Open .dat/.lss/.lsm file.
struct s_T2FSNodePath T2FSNodePath
int t2fs_node_read_branch(T2FSContext *ctx, T2FSNode *node)
Read child branch node(s).
T2FSStatus
Definition t2fs.h:281
@ T2FS_OK
Definition t2fs.h:282
@ T2FS_ERROR
Definition t2fs.h:283
size_t t2fs_read_callback(T2FSInput *input, void *dest, size_t size)
Definition t2fs.h:55
size_t t2fs_read_value_callback(T2FSInput *input, void *dest, t2fsReadSize size)
Definition t2fs.h:56
struct s_T2FSContext T2FSContext
This is the core LibT2FS object that you will be passing around.
Definition t2fs.h:53
T2FSNode * t2fs_node_find_by_name(T2FSNode *start, const char *name, uint32_t level, uint32_t maxLevel)
Find child node by schema name.
int t2fs_seek_callback(T2FSInput *input, long offset, int whence)
Definition t2fs.h:57
struct s_T2FSInput T2FSInput
object to handle input reading
Definition t2fs.h:54
int t2fs_node_read_recurse(T2FSContext *ctx, T2FSNode *node, uint8_t loadData)
Recursive read all child branch node(s) and optionally load the endpoint(s) data.
void t2fs_init(T2FSContext *ctx)
Always initialize your T2FSContext object.
void t2fs_close(T2FSContext *ctx)
Close opened file and free all allocated node/data memory.
int t2fs_node_path_to_string(const T2FSNodePath *const np, char *buf, size_t bufsize)