From c29d5906d2d3c381bc974abfe505a0398c36f0c0 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 28 Dec 2017 04:07:31 +0100 Subject: [PATCH] okay so why exactly are we using seek instead of tell/size --- libretro-db/libretrodb.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/libretro-db/libretrodb.c b/libretro-db/libretrodb.c index e9c21ba04a..dd9d6c5c33 100644 --- a/libretro-db/libretrodb.c +++ b/libretro-db/libretrodb.c @@ -143,7 +143,7 @@ int libretrodb_create(RFILE *fd, libretrodb_value_provider value_provider, struct rmsgpack_dom_value item; uint64_t item_count = 0; libretrodb_header_t header = {{0}}; - ssize_t root = filestream_seek(fd, 0, RETRO_VFS_SEEK_POSITION_CURRENT); + ssize_t root = filestream_tell(fd); memcpy(header.magic_number, MAGIC_NUMBER, sizeof(MAGIC_NUMBER)-1); @@ -230,7 +230,7 @@ int libretrodb_open(const char *path, libretrodb_t *db) free(db->path); db->path = strdup(path); - db->root = filestream_seek(fd, 0, RETRO_VFS_SEEK_POSITION_CURRENT); + db->root = filestream_tell(fd); if ((rv = (int)filestream_read(fd, &header, sizeof(header))) == -1) { @@ -255,8 +255,7 @@ int libretrodb_open(const char *path, libretrodb_t *db) } db->count = md.count; - db->first_index_offset = filestream_seek(fd, 0, - RETRO_VFS_SEEK_POSITION_CURRENT); + db->first_index_offset = filestream_tell(fd); db->fd = fd; return 0; @@ -269,8 +268,7 @@ error: static int libretrodb_find_index(libretrodb_t *db, const char *index_name, libretrodb_index_t *idx) { - ssize_t eof = filestream_seek(db->fd, 0, - RETRO_VFS_SEEK_POSITION_END); + ssize_t eof = filestream_get_size(db->fd); ssize_t offset = filestream_seek(db->fd, (ssize_t)db->first_index_offset, RETRO_VFS_SEEK_POSITION_START); @@ -282,8 +280,9 @@ static int libretrodb_find_index(libretrodb_t *db, const char *index_name, if (strncmp(index_name, idx->name, strlen(idx->name)) == 0) return 0; - offset = filestream_seek(db->fd, (ssize_t)idx->next, + filestream_seek(db->fd, (ssize_t)idx->next, RETRO_VFS_SEEK_POSITION_CURRENT); + offset = filestream_tell(db->fd); } return -1; @@ -474,8 +473,7 @@ static int node_iter(void *value, void *ctx) static uint64_t libretrodb_tell(libretrodb_t *db) { - return filestream_seek(db->fd, 0, - RETRO_VFS_SEEK_POSITION_CURRENT); + return filestream_tell(db->fd); } static int node_compare(const void *a, const void *b, void *ctx) @@ -490,7 +488,6 @@ int libretrodb_create_index(libretrodb_t *db, struct rmsgpack_dom_value key; libretrodb_index_t idx; struct rmsgpack_dom_value item; - uint64_t idx_header_offset = 0; libretrodb_cursor_t cur = {0}; struct rmsgpack_dom_value *field = NULL; void *buff = NULL; @@ -566,10 +563,7 @@ int libretrodb_create_index(libretrodb_t *db, item_loc = libretrodb_tell(db); } - idx_header_offset = filestream_seek(db->fd, 0, - RETRO_VFS_SEEK_POSITION_END); - - (void)idx_header_offset; + filestream_seek(db->fd, 0, RETRO_VFS_SEEK_POSITION_END); strncpy(idx.name, name, 50);