mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 12:39:54 +00:00
fix selecting 7z archive files other than the first one
This commit is contained in:
parent
1205b12e15
commit
0899cd091e
@ -330,8 +330,6 @@ static int file_archive_decompress_data_to_file(
|
||||
goto end;
|
||||
}
|
||||
|
||||
handle->backend->stream_free(handle->stream);
|
||||
|
||||
#if 0
|
||||
handle->real_checksum = handle->backend->stream_crc_calculate(
|
||||
0, handle->data, size);
|
||||
@ -350,6 +348,8 @@ static int file_archive_decompress_data_to_file(
|
||||
}
|
||||
|
||||
end:
|
||||
handle->backend->stream_free(handle->stream);
|
||||
|
||||
if (handle && handle->data)
|
||||
free(handle->data);
|
||||
return ret;
|
||||
|
@ -58,17 +58,17 @@ static void* sevenzip_stream_new(void)
|
||||
struct sevenzip_context_t *sevenzip_context =
|
||||
(struct sevenzip_context_t*)calloc(1, sizeof(struct sevenzip_context_t));
|
||||
|
||||
memset(sevenzip_context, 0, sizeof(struct sevenzip_context_t));
|
||||
|
||||
/* These are the allocation routines - currently using
|
||||
* the non-standard 7zip choices. */
|
||||
sevenzip_context->allocImp.Alloc = SzAlloc;
|
||||
sevenzip_context->allocImp.Free = SzFree;
|
||||
sevenzip_context->allocTempImp.Alloc = SzAllocTemp;
|
||||
sevenzip_context->allocTempImp.Free = SzFreeTemp;
|
||||
sevenzip_context->index = 0;
|
||||
sevenzip_context->packIndex = 0;
|
||||
sevenzip_context->temp_size = 0;
|
||||
sevenzip_context->block_index = 0xFFFFFFFF;
|
||||
sevenzip_context->output = NULL;
|
||||
sevenzip_context->handle = NULL;
|
||||
|
||||
return sevenzip_context;
|
||||
}
|
||||
@ -80,6 +80,13 @@ static void sevenzip_stream_free(void *data)
|
||||
if (!sevenzip_context)
|
||||
return;
|
||||
|
||||
if (sevenzip_context->output)
|
||||
{
|
||||
IAlloc_Free(&sevenzip_context->allocImp, sevenzip_context->output);
|
||||
sevenzip_context->output = NULL;
|
||||
sevenzip_context->handle->data = NULL;
|
||||
}
|
||||
|
||||
SzArEx_Free(&sevenzip_context->db, &sevenzip_context->allocImp);
|
||||
File_Close(&sevenzip_context->archiveStream.file);
|
||||
}
|
||||
@ -253,8 +260,22 @@ static int sevenzip_stream_decompress_data_to_file_iterate(void *data)
|
||||
struct sevenzip_context_t *sevenzip_context =
|
||||
(struct sevenzip_context_t*)data;
|
||||
|
||||
SRes res = SZ_ERROR_FAIL;
|
||||
size_t output_size = 0;
|
||||
size_t offset = 0;
|
||||
size_t outSizeProcessed = 0;
|
||||
|
||||
res = SzArEx_Extract(&sevenzip_context->db,
|
||||
&sevenzip_context->lookStream.s, sevenzip_context->index,
|
||||
&sevenzip_context->block_index, &sevenzip_context->output,
|
||||
&output_size, &offset, &outSizeProcessed,
|
||||
&sevenzip_context->allocImp, &sevenzip_context->allocTempImp);
|
||||
|
||||
if (res != SZ_OK)
|
||||
return 0;
|
||||
|
||||
if (sevenzip_context->handle)
|
||||
sevenzip_context->handle->data = sevenzip_context->output;
|
||||
sevenzip_context->handle->data = sevenzip_context->output + offset;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -262,14 +283,16 @@ static int sevenzip_stream_decompress_data_to_file_iterate(void *data)
|
||||
static int sevenzip_parse_file_init(file_archive_transfer_t *state,
|
||||
const char *file)
|
||||
{
|
||||
struct sevenzip_context_t *sevenzip_context = NULL;
|
||||
struct sevenzip_context_t *sevenzip_context =
|
||||
(struct sevenzip_context_t*)sevenzip_stream_new();
|
||||
|
||||
if (state->archive_size < SEVENZIP_MAGIC_LEN)
|
||||
return -1;
|
||||
|
||||
if (memcmp(state->data, SEVENZIP_MAGIC, SEVENZIP_MAGIC_LEN) != 0)
|
||||
return -1;
|
||||
|
||||
sevenzip_context = (struct sevenzip_context_t*)sevenzip_stream_new();
|
||||
state->stream = sevenzip_context;
|
||||
|
||||
/* could not open 7zip archive? */
|
||||
if (InFile_Open(&sevenzip_context->archiveStream.file, file))
|
||||
@ -282,10 +305,11 @@ static int sevenzip_parse_file_init(file_archive_transfer_t *state,
|
||||
CrcGenerateTable();
|
||||
SzArEx_Init(&sevenzip_context->db);
|
||||
|
||||
SzArEx_Open(&sevenzip_context->db, &sevenzip_context->lookStream.s,
|
||||
SRes res = SzArEx_Open(&sevenzip_context->db, &sevenzip_context->lookStream.s,
|
||||
&sevenzip_context->allocImp, &sevenzip_context->allocTempImp);
|
||||
|
||||
state->stream = sevenzip_context;
|
||||
if (res != SZ_OK)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -301,7 +325,8 @@ static int sevenzip_parse_file_iterate_step_internal(
|
||||
|
||||
if (sevenzip_context->index < sevenzip_context->db.db.NumFiles)
|
||||
{
|
||||
size_t len = SzArEx_GetFileNameUtf16(&sevenzip_context->db, sevenzip_context->index, NULL);
|
||||
size_t len = SzArEx_GetFileNameUtf16(&sevenzip_context->db,
|
||||
sevenzip_context->index, NULL);
|
||||
uint64_t compressed_size = 0;
|
||||
|
||||
if (sevenzip_context->packIndex < sevenzip_context->db.db.NumPackStreams)
|
||||
@ -319,7 +344,8 @@ static int sevenzip_parse_file_iterate_step_internal(
|
||||
if (!temp)
|
||||
return -1;
|
||||
|
||||
SzArEx_GetFileNameUtf16(&sevenzip_context->db, sevenzip_context->index, temp);
|
||||
SzArEx_GetFileNameUtf16(&sevenzip_context->db, sevenzip_context->index,
|
||||
temp);
|
||||
|
||||
if (temp)
|
||||
{
|
||||
@ -333,22 +359,6 @@ static int sevenzip_parse_file_iterate_step_internal(
|
||||
|
||||
strlcpy(filename, infile, PATH_MAX_LENGTH);
|
||||
|
||||
if (!userdata->list_only)
|
||||
{
|
||||
size_t output_size = 0;
|
||||
size_t offset = 0;
|
||||
size_t outSizeProcessed = 0;
|
||||
|
||||
res = SzArEx_Extract(&sevenzip_context->db,
|
||||
&sevenzip_context->lookStream.s, sevenzip_context->index,
|
||||
&sevenzip_context->block_index, &sevenzip_context->output,
|
||||
&output_size, &offset, &outSizeProcessed,
|
||||
&sevenzip_context->allocImp, &sevenzip_context->allocTempImp);
|
||||
}
|
||||
|
||||
if (res != SZ_OK)
|
||||
return -1;
|
||||
|
||||
*cmode = ARCHIVE_MODE_COMPRESSED;
|
||||
*checksum = file->Crc;
|
||||
*size = file->Size;
|
||||
|
Loading…
x
Reference in New Issue
Block a user