From e3be7db2c856dc67286a5c873f65af1f40126f46 Mon Sep 17 00:00:00 2001 From: pixel Date: Mon, 9 Jul 2007 20:26:02 +0000 Subject: mpq-file almost done. --- mpq-bios.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mpq-bios.c') diff --git a/mpq-bios.c b/mpq-bios.c index abac013..4051627 100644 --- a/mpq-bios.c +++ b/mpq-bios.c @@ -336,13 +336,13 @@ int mpqlib_find_hash_entry_by_hash(struct mpq_archive_t * mpq_a, uint32_t hA, ui return -1; } -int __mpqlib_seek(struct mpq_archive_t * mpq_a, off_t off) { +int __mpqlib_seek(struct mpq_archive_t * mpq_a, uint64_t off) { if (lseek64(mpq_a->fd, off, SEEK_SET) != off) return 0; return 1; } -int __mpqlib_read(struct mpq_archive_t * mpq_a, void * buffer, size_t size) { +int __mpqlib_read(struct mpq_archive_t * mpq_a, void * buffer, uint32_t size) { return read_data(mpq_a, buffer, size); } @@ -354,15 +354,18 @@ uint64_t mpqlib_ioctl(struct mpq_archive_t * mpq_a, enum mpqlib_ioctl_t command, return mpq_a->format_version; case MPQLIB_IOCTL_GET_SECTOR_SIZE: return mpq_a->sector_size; + case MPQLIB_IOCTL_ENTRY_EXISTS: case MPQLIB_IOCTL_GET_BLOCK_OFFSET: case MPQLIB_IOCTL_GET_BLOCK_SIZE: case MPQLIB_IOCTL_GET_FILE_SIZE: case MPQLIB_IOCTL_GET_FLAGS: - if (entry >= mpq_a->block_table_entries) { + if ((entry >= mpq_a->block_table_entries) || (entry < 0)) { __mpqlib_errno = MPQLIB_ERROR_IOCTL_INVALID_ENTRY; return -1; } switch (command) { + case MPQLIB_IOCTL_ENTRY_EXISTS: + return 0; case MPQLIB_IOCTL_GET_BLOCK_OFFSET: return mpq_a->blocks[entry].block_offset; case MPQLIB_IOCTL_GET_BLOCK_SIZE: -- cgit v1.2.3