mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 00:39:53 +00:00
okay so why exactly are we using seek instead of tell/size
This commit is contained in:
parent
b933a8796b
commit
c29d5906d2
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user