diff options
author | Pixel <pixel@nobis-crew.org> | 2009-08-06 18:49:37 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-08-06 18:49:37 -0700 |
commit | 15bea2c4a9f1161712bb381351a6b83ffb90f8d8 (patch) | |
tree | 4147c75416301f6363a993108a3b6b8779ed2bc8 /mpq-bios.c | |
parent | 6b5b44074fd6bdbbeb59f8d006fb88e0230cf1ef (diff) |
Adding the mpqlib_update_hash_entry functions.
Diffstat (limited to 'mpq-bios.c')
-rw-r--r-- | mpq-bios.c | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -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; |