Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion libretro-common/file/archive_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,21 @@ const struct file_archive_file_backend* file_archive_get_file_backend(const char
* file found inside is used.
**/
uint32_t file_archive_get_file_crc32(const char *path)
{
uint64_t file_size;
return file_archive_get_file_crc32_and_size(path, &file_size);
}

/**
* file_archive_get_file_crc32_and_size:
* @path : filename path of archive
* @size : size of the file inside the 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_and_size(const char *path, uint64_t *size)
{
file_archive_transfer_t state;
struct archive_extract_userdata userdata = {0};
Expand Down Expand Up @@ -713,6 +728,6 @@ uint32_t file_archive_get_file_crc32(const char *path)
}

file_archive_parse_file_iterate_stop(&state);

*size = userdata.size;
return userdata.crc;
}
1 change: 1 addition & 0 deletions libretro-common/file/archive_file_7z.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ static int sevenzip_parse_file_iterate_step(void *context,
return ret;

userdata->crc = checksum;
userdata->size = size;

if (file_cb && !file_cb(userdata->current_file_path, valid_exts,
cdata, cmode,
Expand Down
3 changes: 2 additions & 1 deletion libretro-common/file/archive_file_zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ static int zip_parse_file_iterate_step(void *context,
if (ret != 1)
return ret;

userdata->crc = checksum;
userdata->crc = checksum;
userdata->size = size;

if (file_cb && !file_cb(userdata->current_file_path, valid_exts, cdata, cmode,
csize, size, checksum, userdata))
Expand Down
12 changes: 12 additions & 0 deletions libretro-common/include/file/archive_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct archive_extract_userdata
decompress_state_t *dec;
void* cb_data;
uint32_t crc;
uint64_t size;
char archive_path[PATH_MAX_LENGTH];
char current_file_path[PATH_MAX_LENGTH];
bool found_file;
Expand Down Expand Up @@ -202,6 +203,17 @@ const struct file_archive_file_backend* file_archive_get_file_backend(const char
**/
uint32_t file_archive_get_file_crc32(const char *path);

/**
* file_archive_get_file_crc32_and_size:
* @path : filename path of archive
* @size : size of the file inside the 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_and_size(const char *path, uint64_t *size);

extern const struct file_archive_file_backend zlib_backend;
extern const struct file_archive_file_backend sevenzip_backend;

Expand Down
Loading