3rdparty/libchdr: Purge now unused patches

This commit is contained in:
TheLastRar 2024-12-14 14:47:56 +00:00 committed by Ty
parent a7b07eb53f
commit 3b89020082
2 changed files with 18 additions and 59 deletions

View File

@ -290,8 +290,7 @@ enum _chd_error
CHDERR_INVALID_STATE, CHDERR_INVALID_STATE,
CHDERR_OPERATION_PENDING, CHDERR_OPERATION_PENDING,
CHDERR_NO_ASYNC_OPERATION, CHDERR_NO_ASYNC_OPERATION,
CHDERR_UNSUPPORTED_FORMAT, CHDERR_UNSUPPORTED_FORMAT
CHDERR_CANCELLED,
}; };
typedef enum _chd_error chd_error; typedef enum _chd_error chd_error;
@ -383,7 +382,6 @@ CHD_EXPORT chd_error chd_open(const char *filename, int mode, chd_file *parent,
/* precache underlying file */ /* precache underlying file */
CHD_EXPORT chd_error chd_precache(chd_file *chd); CHD_EXPORT chd_error chd_precache(chd_file *chd);
CHD_EXPORT chd_error chd_precache_progress(chd_file* chd, bool(*progress)(size_t pos, size_t total, void* param), void* param);
/* close a CHD file */ /* close a CHD file */
CHD_EXPORT void chd_close(chd_file *chd); CHD_EXPORT void chd_close(chd_file *chd);
@ -391,9 +389,6 @@ CHD_EXPORT void chd_close(chd_file *chd);
/* return the associated core_file */ /* return the associated core_file */
CHD_EXPORT core_file *chd_core_file(chd_file *chd); CHD_EXPORT core_file *chd_core_file(chd_file *chd);
/* return the overall size of a CHD, and any of its parents */
CHD_EXPORT UINT64 chd_get_compressed_size(chd_file* chd);
/* return an error string for the given CHD error */ /* return an error string for the given CHD error */
CHD_EXPORT const char *chd_error_string(chd_error err); CHD_EXPORT const char *chd_error_string(chd_error err);

View File

@ -1953,56 +1953,28 @@ cleanup:
CHD_EXPORT chd_error chd_precache(chd_file* chd) CHD_EXPORT chd_error chd_precache(chd_file* chd)
{ {
return chd_precache_progress(chd, NULL, NULL); INT64 count;
} UINT64 size;
CHD_EXPORT chd_error chd_precache_progress(chd_file* chd, bool(*progress)(size_t pos, size_t total, void* param), void* param) if (chd->file_cache == NULL)
{ {
#define PRECACHE_CHUNK_SIZE 16 * 1024 * 1024 size = core_fsize(chd->file);
if ((INT64)size <= 0)
if (chd->file_cache == NULL) return CHDERR_INVALID_DATA;
{ chd->file_cache = malloc(size);
const UINT64 size = core_fsize(chd->file); if (chd->file_cache == NULL)
if ((INT64)size <= 0)
return CHDERR_INVALID_DATA;
if (size > SIZE_MAX)
return CHDERR_OUT_OF_MEMORY; return CHDERR_OUT_OF_MEMORY;
core_fseek(chd->file, 0, SEEK_SET);
chd->file_cache = malloc(size); count = core_fread(chd->file, chd->file_cache, size);
if (chd->file_cache == NULL) if (count != size)
return CHDERR_OUT_OF_MEMORY;
core_fseek(chd->file, 0, SEEK_SET);
UINT64 done = 0;
while (done < size)
{ {
UINT64 req_count = size - done; free(chd->file_cache);
if (req_count > PRECACHE_CHUNK_SIZE) chd->file_cache = NULL;
req_count = PRECACHE_CHUNK_SIZE; return CHDERR_READ_ERROR;
size_t count = core_fread(chd->file, chd->file_cache + (size_t)done, (size_t)req_count);
if (count != (size_t)req_count)
{
free(chd->file_cache);
chd->file_cache = NULL;
return CHDERR_READ_ERROR;
}
done += req_count;
if (progress != NULL)
{
if (!progress(done, size, param))
{
free(chd->file_cache);
chd->file_cache = NULL;
return CHDERR_CANCELLED;
}
}
} }
} }
return CHDERR_NONE; return CHDERR_NONE;
} }
/*------------------------------------------------- /*-------------------------------------------------
@ -2169,14 +2141,6 @@ CHD_EXPORT core_file *chd_core_file(chd_file *chd)
return chd->file; return chd->file;
} }
CHD_EXPORT UINT64 chd_get_compressed_size(chd_file *chd)
{
UINT64 size = chd->file->fsize(chd->file);
if (chd->parent)
size += chd_get_compressed_size(chd->parent);
return size;
}
/*------------------------------------------------- /*-------------------------------------------------
chd_error_string - return an error string for chd_error_string - return an error string for
the given CHD error the given CHD error