Build libpakrd with cmake instead of using it as prebuilt library

This commit is contained in:
abdelrahman committed 2023-11-05 19:15:56 +00:00
1 parent c5dd826c66
commit 2de3e9b4df
12 files changed
+442 -15

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
#ifndef PATH_UTILS_H
#define PATH_UTILS_H
#include "aliases.h"
#define NUMPARTS(...) \
(sizeof((const char *[]){"", __VA_ARGS__}) / sizeof(const char *) - 1)
#define JOIN_PATH(DST, ...) join_path(DST, NUMPARTS(__VA_ARGS__), __VA_ARGS__)
void join_path(char *dst, u64 count, ...);
#define DIRNAME(DST, PATH) dirup(DST, 1, PATH)
#define DIRUP(DST, COUNT, PATH) dirup(DST, COUNT, PATH)
void dirup(char *dst, u64 levels, const char *path);
#endif // !PATH_UTILS_H
+24
View File
@@ -0,0 +1,24 @@
#ifndef D_ARR_H
#define D_ARR_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include "aliases.h"
#include <stdbool.h>
#define INVALID_IDX -1
typedef struct darr darr_t;
bool darr_init(darr_t **darr);
i64 darr_add(darr_t **darr, void *item);
void **darr_get_items(darr_t *darr);
void darr_free(darr_t **darr);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !D_ARR_H
+25
View File
@@ -0,0 +1,25 @@
#ifndef IO_H
#define IO_H
#include "SDL_rwops.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include "aliases.h"
#include <linux/limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#define STREQ(S1, S2) (strcmp(S1, S2) == 0)
#define STRNEQ(S1, S2, COUNT) (strncmp(S1, S2, COUNT) == 0)
u64 get_file_length(SDL_RWops *io);
void read_entire_file(void *dst, SDL_RWops *io);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !IO_H
+50
View File
@@ -0,0 +1,50 @@
#ifndef PAK_H
#define PAK_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include "aliases.h"
#include <stdbool.h>
typedef struct {
u64 size;
u8 data[];
} buf_t;
typedef struct {
u64 offset;
u64 length;
char name[];
} toc_entry_t;
typedef struct {
u64 count;
u64 size;
} toc_t;
typedef struct {
u64 major;
u64 minor;
u64 patch;
} pak_ver_t;
typedef struct {
u64 magic;
pak_ver_t version;
toc_t toc;
} pak_t;
typedef struct asset_pack asset_pack_t;
asset_pack_t *load_asset_pack(const char *filepath);
buf_t *read_file_from_pack(asset_pack_t *pack, const char *filename);
void close_pack_file(buf_t **buf);
void close_asset_pack(asset_pack_t **pack);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !PAK_H