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 | |
parent | 6b5b44074fd6bdbbeb59f8d006fb88e0230cf1ef (diff) |
Adding the mpqlib_update_hash_entry functions.
-rw-r--r-- | mpq-bios.c | 29 | ||||
-rw-r--r-- | mpq-bios.h | 8 |
2 files changed, 32 insertions, 5 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; @@ -41,10 +41,12 @@ struct mpq_archive_t * mpqlib_open_archive_for_writing(const char * fname); struct mpq_archive_t * mpqlib_reopen_archive(int fd); void mpqlib_printtables(struct mpq_archive_t *); void mpqlib_close_archive(struct mpq_archive_t *); -int mpqlib_find_hash_entry_by_name(struct mpq_archive_t *, const char * name, uint16_t language, uint16_t platform); -int mpqlib_find_hash_entry_by_hash(struct mpq_archive_t *, uint32_t h, uint32_t hA, uint32_t hB, uint16_t language, uint16_t platform); -int mpqlib_add_hash_entry_by_name(struct mpq_archive_t *, const char * name, uint16_t language, uint16_t platform, int entry); +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); +int mpqlib_update_hash_entry_by_name(struct mpq_archive_t * mpq_a, const char * name, uint16_t language, uint16_t platform, int entry); int mpqlib_add_hash_entry_by_hash(struct mpq_archive_t *, uint32_t h, uint32_t hA, uint32_t hB, uint16_t language, uint16_t, int entry); +int mpqlib_add_hash_entry_by_name(struct mpq_archive_t *, const char * name, uint16_t language, uint16_t platform, int entry); +int mpqlib_find_hash_entry_by_hash(struct mpq_archive_t *, uint32_t h, uint32_t hA, uint32_t hB, uint16_t language, uint16_t platform); +int mpqlib_find_hash_entry_by_name(struct mpq_archive_t *, const char * name, uint16_t language, uint16_t platform); uint64_t mpqlib_ioctl(struct mpq_archive_t *, enum mpqlib_ioctl_t command, ...); #ifdef __cplusplus |