refactor some things...
This commit is contained in:
parent
3550fad638
commit
1744e689b5
25 changed files with 2396 additions and 1307 deletions
|
|
@ -10,6 +10,14 @@
|
|||
#include "pxl8_cart.h"
|
||||
#include "pxl8_macros.h"
|
||||
|
||||
struct pxl8_cart {
|
||||
void* archive_data;
|
||||
size_t archive_size;
|
||||
char* base_path;
|
||||
bool is_folder;
|
||||
bool is_mounted;
|
||||
char* name;
|
||||
};
|
||||
|
||||
static pxl8_cart* __pxl8_current_cart = NULL;
|
||||
static char* __pxl8_original_cwd = NULL;
|
||||
|
|
@ -73,10 +81,29 @@ static bool is_pxc_file(const char* path) {
|
|||
return len > 4 && strcmp(path + len - 4, ".pxc") == 0;
|
||||
}
|
||||
|
||||
pxl8_cart* pxl8_cart_create(void) {
|
||||
pxl8_cart* cart = calloc(1, sizeof(pxl8_cart));
|
||||
return cart;
|
||||
}
|
||||
|
||||
pxl8_cart* pxl8_cart_current(void) {
|
||||
return __pxl8_current_cart;
|
||||
}
|
||||
|
||||
void pxl8_cart_destroy(pxl8_cart* cart) {
|
||||
if (!cart) return;
|
||||
pxl8_cart_unload(cart);
|
||||
free(cart);
|
||||
}
|
||||
|
||||
const char* pxl8_cart_get_base_path(const pxl8_cart* cart) {
|
||||
return cart ? cart->base_path : NULL;
|
||||
}
|
||||
|
||||
const char* pxl8_cart_get_name(const pxl8_cart* cart) {
|
||||
return cart ? cart->name : NULL;
|
||||
}
|
||||
|
||||
pxl8_result pxl8_cart_load(pxl8_cart* cart, const char* path) {
|
||||
if (!cart || !path) return PXL8_ERROR_NULL_POINTER;
|
||||
|
||||
|
|
@ -146,8 +173,8 @@ pxl8_result pxl8_cart_load(pxl8_cart* cart, const char* path) {
|
|||
return PXL8_ERROR_INVALID_FORMAT;
|
||||
}
|
||||
|
||||
int num_files = mz_zip_reader_get_num_files(&zip);
|
||||
for (int i = 0; i < num_files; i++) {
|
||||
i32 num_files = mz_zip_reader_get_num_files(&zip);
|
||||
for (i32 i = 0; i < num_files; i++) {
|
||||
mz_zip_archive_file_stat file_stat;
|
||||
if (!mz_zip_reader_file_stat(&zip, i, &file_stat)) continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue