This commit is contained in:
asrael 2025-11-01 12:39:59 -05:00
parent e862b02019
commit 0ed7fc4496
No known key found for this signature in database
GPG key ID: 2786557804DFAE24
21 changed files with 1267 additions and 148 deletions

View file

@ -288,25 +288,20 @@ void pxl8_cart_unmount(pxl8_cart* cart) {
pxl8_info("Unmounted cart: %s", cart->name);
}
char* pxl8_cart_resolve_path(const pxl8_cart* cart, const char* relative_path) {
if (!cart || !cart->base_path || !relative_path) return NULL;
bool pxl8_cart_resolve_path(const pxl8_cart* cart, const char* relative_path, char* out_path, size_t out_size) {
if (!cart || !cart->base_path || !relative_path || !out_path || out_size == 0) return false;
char* full_path = malloc(512);
if (!full_path) return NULL;
snprintf(full_path, 512, "%s/%s", cart->base_path, relative_path);
return full_path;
i32 written = snprintf(out_path, out_size, "%s/%s", cart->base_path, relative_path);
return written >= 0 && (size_t)written < out_size;
}
bool pxl8_cart_file_exists(const pxl8_cart* cart, const char* path) {
if (!cart || !cart->base_path || !path) return false;
char* full_path = pxl8_cart_resolve_path(cart, path);
if (!full_path) return false;
char full_path[512];
if (!pxl8_cart_resolve_path(cart, path, full_path, sizeof(full_path))) return false;
bool exists = access(full_path, F_OK) == 0;
free(full_path);
return exists;
return access(full_path, F_OK) == 0;
}
pxl8_result pxl8_cart_pack(const char* folder_path, const char* output_path) {