static void rarch_task_decompress_handler_subdir(rarch_task_t *task) { bool retdec; decompress_state_t *dec = (decompress_state_t*)task->state; int ret = file_archive_parse_file_iterate(&dec->zlib, &retdec, dec->source_file, dec->valid_ext, file_decompressed_subdir, dec); task->progress = file_archive_parse_file_progress(&dec->zlib); if (task->cancelled || ret != 0) { task->error = dec->callback_error; file_archive_parse_file_iterate_stop(&dec->zlib); rarch_task_decompress_handler_finished(task, dec); } }
static int zip_file_read( const char *path, const char *needle, void **buf, const char *optional_outfile) { file_archive_transfer_t zlib; struct archive_extract_userdata userdata = {{0}}; bool returnerr = true; int ret = 0; zlib.type = ARCHIVE_TRANSFER_INIT; userdata.decomp_state.needle = NULL; userdata.decomp_state.opt_file = NULL; userdata.decomp_state.found = false; userdata.decomp_state.buf = buf; if (needle) userdata.decomp_state.needle = strdup(needle); if (optional_outfile) userdata.decomp_state.opt_file = strdup(optional_outfile); do { ret = file_archive_parse_file_iterate(&zlib, &returnerr, path, "", zip_file_decompressed, &userdata); if (!returnerr) break; }while(ret == 0 && !userdata.decomp_state.found); file_archive_parse_file_iterate_stop(&zlib); if (userdata.decomp_state.opt_file) free(userdata.decomp_state.opt_file); if (userdata.decomp_state.needle) free(userdata.decomp_state.needle); if (!userdata.decomp_state.found) return -1; return (int)userdata.decomp_state.size; }
static int content_zip_file_read( const char *path, const char *needle, void **buf, const char* optional_outfile) { file_archive_transfer_t zlib; struct decomp_state st; bool returnerr = true; int ret = 0; zlib.type = ZLIB_TRANSFER_INIT; st.needle = NULL; st.opt_file = NULL; st.found = false; st.buf = buf; if (needle) st.needle = strdup(needle); if (optional_outfile) st.opt_file = strdup(optional_outfile); do { ret = file_archive_parse_file_iterate(&zlib, &returnerr, path, "", content_zip_file_decompressed, &st); if (!returnerr) break; }while(ret == 0 && !st.found); file_archive_parse_file_iterate_stop(&zlib); if (st.opt_file) free(st.opt_file); if (st.needle) free(st.needle); if (!st.found) return -1; return st.size; }
static int task_database_iterate_playlist_zip( database_state_handle_t *db_state, database_info_handle_t *db, const char *name) { bool returnerr = true; #ifdef HAVE_ZLIB if (db_state->crc != 0) return task_database_iterate_crc_lookup( db_state, db, db_state->zip_name); if (file_archive_parse_file_iterate(&db->state, &returnerr, name, NULL, zlib_compare_crc32, (void*)db_state) != 0) return 0; if (db_state->crc) file_archive_parse_file_iterate_stop(&db->state); #endif return 1; }
/** * file_archive_get_file_crc32: * @path : filename path of archive * * Returns: CRC32 of the specified file in the archive, otherwise 0. * If no path within the archive is specified, the first * file found inside is used. **/ uint32_t file_archive_get_file_crc32(const char *path) { file_archive_transfer_t state; const struct file_archive_file_backend *backend = file_archive_get_file_backend(path); struct archive_extract_userdata userdata = {{0}}; bool returnerr = false; bool contains_compressed = false; const char *archive_path = NULL; if (!backend) return 0; contains_compressed = path_contains_compressed_file(path); if (contains_compressed) { archive_path = path_get_archive_delim(path); /* move pointer right after the delimiter to give us the path */ if (archive_path) archive_path += 1; } state.type = ARCHIVE_TRANSFER_INIT; state.archive_size = 0; state.handle = NULL; state.stream = NULL; state.footer = NULL; state.directory = NULL; state.data = NULL; state.backend = NULL; /* Initialize and open archive first. Sets next state type to ITERATE. */ file_archive_parse_file_iterate(&state, &returnerr, path, NULL, NULL, &userdata); for (;;) { /* Now find the first file in the archive. */ if (state.type == ARCHIVE_TRANSFER_ITERATE) file_archive_parse_file_iterate(&state, &returnerr, path, NULL, NULL, &userdata); /* If no path specified within archive, stop after * finding the first file. */ if (!contains_compressed) break; /* Stop when the right file in the archive is found. */ if (archive_path) { if (string_is_equal(userdata.extracted_file_path, archive_path)) break; } else break; } file_archive_parse_file_iterate_stop(&state); if (userdata.crc) return userdata.crc; return 0; }