From 15bea2c4a9f1161712bb381351a6b83ffb90f8d8 Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 6 Aug 2009 18:49:37 -0700 Subject: Adding the mpqlib_update_hash_entry functions. --- mpq-bios.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'mpq-bios.c') diff --git a/mpq-bios.c b/mpq-bios.c index 93c0623..eeba42a 100644 --- a/mpq-bios.c +++ b/mpq-bios.c @@ -490,14 +490,29 @@ int mpqlib_add_hash_entry_by_name(struct mpq_archive_t * mpq_a, const char * nam return mpqlib_add_hash_entry_by_hash(mpq_a, h, hA, hB, language, platform, entry); } -int mpqlib_find_hash_entry_by_name(struct mpq_archive_t * mpq_a, const char * name, uint16_t language, uint16_t platform) { +int mpqlib_update_hash_entry_by_hash(struct mpq_archive_t * mpq_a, uint32_t h, uint32_t hA, uint32_t hB, uint16_t language, uint16_t platform, int entry) { + if (!mpq_a->for_write) { + __mpqlib_errno = MPQLIB_ERROR_READONLY; + return -1; + } + + hash_t * hash = mpqlib_locate_hash_entry(mpq_a, h, hA, hB, language, platform); + + if (hash) { + hash->file_block_index = entry; + return 0; + } + return -1; +} + +int mpqlib_update_hash_entry_by_name(struct mpq_archive_t * mpq_a, const char * name, uint16_t language, uint16_t platform, int entry) { uint32_t h, hA, hB; h = mpqlib_hash_filename(name); hA = mpqlib_hashA_filename(name); hB = mpqlib_hashB_filename(name); - return mpqlib_find_hash_entry_by_hash(mpq_a, h, hA, hB, language, platform); + return mpqlib_update_hash_entry_by_hash(mpq_a, h, hA, hB, language, platform, entry); } int mpqlib_find_hash_entry_by_hash(struct mpq_archive_t * mpq_a, uint32_t h, uint32_t hA, uint32_t hB, uint16_t language, uint16_t platform) { @@ -509,6 +524,16 @@ int mpqlib_find_hash_entry_by_hash(struct mpq_archive_t * mpq_a, uint32_t h, uin return -1; } +int mpqlib_find_hash_entry_by_name(struct mpq_archive_t * mpq_a, const char * name, uint16_t language, uint16_t platform) { + uint32_t h, hA, hB; + + h = mpqlib_hash_filename(name); + hA = mpqlib_hashA_filename(name); + hB = mpqlib_hashB_filename(name); + + return mpqlib_find_hash_entry_by_hash(mpq_a, h, hA, hB, language, platform); +} + uint64_t mpqlib_ioctl(struct mpq_archive_t * mpq_a, enum mpqlib_ioctl_t command, ...) { __mpqlib_errno = MPQLIB_ERROR_NO_ERROR; int r = 0; -- cgit v1.2.3