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:28
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
t2fsSchemaNode * schema
Definition t2fs.h:115
uint8_t isCompressed
Indicator that the data is compressed.
Definition t2fs.h:176
uint8_t hasBeenRead
Indicator that the data for this node has been read.
Definition t2fs.h:180
t2fsNode * childNodes
Pointer to the child node(s).
Definition t2fs.h:172
t2fsInput * input
For reading data.
Definition t2fs.h:155
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
t_t2fs * lib
Pointer to our context for convenience.
Definition t2fs.h:184
uint32_t size
Data size of this node.
Definition t2fs.h:136
uint32_t offset
Offset to this node.
Definition t2fs.h:128
uint32_t id
Index of this node.
Definition t2fs.h:119
uint32_t childCount
How many child nodes this node has.
Definition t2fs.h:166
t2fsNode * parent
The parent node.
Definition t2fs.h:161
This is the core LibT2FS object that you will be passing around.
Definition t2fs.h:289
t_rnc rnc
RNC decompression context.
Definition t2fs.h:308
t2fsNode * spawnpoints
Definition t2fs.h:314
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 * models
Definition t2fs.h:311
t2fsNode * textures
Definition t2fs.h:312
t2fsNode * scenes
Definition t2fs.h:315
t2fsInput input
File input reading.
Definition t2fs.h:300
t2fsNode root
Root node.
Definition t2fs.h:304
enum e_t2fsReadSize t2fsReadSize
To handle swapping endianness.
int t2fs_node_guess_read_recursive(t_t2fs *lib, t2fsNode *node, uint8_t loadData, uint8_t decompress)
void t2fs_node_init(t2fsNode *node)
int t2fs_seek_callback(t2fsInput *input, long offset, int whence)
Definition t2fs.h:57
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_print_error_node(int printType, const char *const func, t2fsNode *node, const char *const fmt,...)
int t2fs_node_read_data(t2fsNode *node)
Read node data.
void t2fs_close(t_t2fs *lib)
Close opened file and free all allocated node/data memory.
void t2fs_node_free_childeren(t2fsNode *node)
This should be called after successfully call to t2fs_node_read_branch().
int t2fs_node_read_recurse(t_t2fs *lib, t2fsNode *node, uint8_t loadData)
Recursive read all child branch node(s) and optionally load the endpoint(s) data.
int t2fs_node_path_to_string(const t2fsNodePath *const np, char *buf, size_t bufsize)
t2fsNode * t2fs_node_find_by_name(t2fsNode *start, const char *name, uint32_t level, uint32_t maxLevel)
Find child node by schema name.
void t2fs_init(t_t2fs *lib)
Always initialize your t_t2fs object.
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
void t2fs_node_print_recursive(const t2fsNode *const node, uint32_t indent)
struct s_t2fsInput t2fsInput
object to handle input reading
Definition t2fs.h:54
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_path_parse(t2fsNodePath *np, t2fsNode *node)
t2fsStatus
Definition t2fs.h:281
@ T2FS_OK
Definition t2fs.h:282
@ T2FS_ERROR
Definition t2fs.h:283
t2fsStatus t2fs_open(t_t2fs *lib, const char *const filepath, const char *const schemaPath, uint8_t searchSchema)
Open .dat/.lss/.lsm file.
struct s_t2fsNode t2fsNode
This is the core object to describe a path inside the tree.
Definition t2fs.h:110
void t2fs_node_path_print(const t_t2fs *const lib, const t2fsNodePath *const np)
struct s_t2fsNodePath t2fsNodePath
void t2fs_node_path_init(t2fsNodePath *np)
struct s_t2fs t_t2fs
This is the core LibT2FS object that you will be passing around.
Definition t2fs.h:53
int t2fs_node_read_branch(t_t2fs *lib, t2fsNode *node)
Read child branch node(s).