static int file_decompressed(const char *name, const char *valid_exts, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, uint32_t crc32, void *userdata) { char path[PATH_MAX_LENGTH]; decompress_state_t *dec = (decompress_state_t*)userdata; /* Ignore directories. */ if (name[strlen(name) - 1] == '/' || name[strlen(name) - 1] == '\\') goto next_file; /* Make directory */ fill_pathname_join(path, dec->target_dir, name, sizeof(path)); path_basedir(path); if (!path_mkdir(path)) goto error; fill_pathname_join(path, dec->target_dir, name, sizeof(path)); if (!zlib_perform_mode(path, valid_exts, cdata, cmode, csize, size, crc32, userdata)) goto error; RARCH_LOG("[deflate] Path: %s, CRC32: 0x%x\n", name, crc32); next_file: return 1; error: dec->callback_error = (char*)malloc(PATH_MAX_LENGTH); snprintf(dec->callback_error, PATH_MAX_LENGTH, "Failed to deflate %s.\n", path); return 0; }
static int zlib_extract_core_callback(const char *name, const char *valid_exts, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, uint32_t crc32, void *userdata) { char path[PATH_MAX_LENGTH]; /* Make directory */ fill_pathname_join(path, (const char*)userdata, name, sizeof(path)); path_basedir(path); if (!path_mkdir(path)) { RARCH_ERR("Failed to create directory: %s.\n", path); return 0; } /* Ignore directories. */ if (name[strlen(name) - 1] == '/' || name[strlen(name) - 1] == '\\') return 1; fill_pathname_join(path, (const char*)userdata, name, sizeof(path)); RARCH_LOG("path is: %s, CRC32: 0x%x\n", path, crc32); if (!zlib_perform_mode(path, valid_exts, cdata, cmode, csize, size, crc32, userdata)) { if (cmode == 0) { RARCH_ERR("Failed to write file: %s.\n", path); return 0; } goto error; } return 1; error: RARCH_ERR("Failed to deflate to: %s.\n", path); return 0; }