mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-21 18:21:51 +00:00
(libretro-common) Update
This commit is contained in:
parent
e41127459e
commit
1b289c0f05
22
cheevos.c
22
cheevos.c
@ -1688,7 +1688,7 @@ static size_t cheevos_eval_md5(
|
||||
}
|
||||
else
|
||||
{
|
||||
RFILE *file = filestream_fopen(info->path, RFILE_MODE_READ, 0);
|
||||
RFILE *file = filestream_open(info->path, RFILE_MODE_READ, 0);
|
||||
size_t size = 0;
|
||||
|
||||
if (!file)
|
||||
@ -1697,7 +1697,7 @@ static size_t cheevos_eval_md5(
|
||||
for (;;)
|
||||
{
|
||||
uint8_t buffer[4096];
|
||||
ssize_t num_read = filestream_fread(file,
|
||||
ssize_t num_read = filestream_read(file,
|
||||
(void*)buffer, sizeof(buffer));
|
||||
|
||||
if (num_read <= 0)
|
||||
@ -1707,7 +1707,7 @@ static size_t cheevos_eval_md5(
|
||||
size += num_read;
|
||||
}
|
||||
|
||||
filestream_fclose(file);
|
||||
filestream_close(file);
|
||||
return size;
|
||||
}
|
||||
}
|
||||
@ -1825,14 +1825,14 @@ static unsigned cheevos_find_game_id_nes(
|
||||
}
|
||||
else
|
||||
{
|
||||
RFILE *file = filestream_fopen(info->path, RFILE_MODE_READ, 0);
|
||||
RFILE *file = filestream_open(info->path, RFILE_MODE_READ, 0);
|
||||
ssize_t num_read;
|
||||
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
num_read = filestream_fread(file, (void*)&header, sizeof(header));
|
||||
filestream_fclose(file);
|
||||
num_read = filestream_read(file, (void*)&header, sizeof(header));
|
||||
filestream_close(file);
|
||||
|
||||
if (num_read < (ssize_t)sizeof(header))
|
||||
return 0;
|
||||
@ -1869,7 +1869,7 @@ static unsigned cheevos_find_game_id_nes(
|
||||
53, 198, 228
|
||||
};
|
||||
bool round = true;
|
||||
RFILE *file = filestream_fopen(info->path, RFILE_MODE_READ, 0);
|
||||
RFILE *file = filestream_open(info->path, RFILE_MODE_READ, 0);
|
||||
uint8_t * data = (uint8_t *) malloc(rom_size << 14);
|
||||
|
||||
if (!file || !data)
|
||||
@ -1897,14 +1897,14 @@ static unsigned cheevos_find_game_id_nes(
|
||||
}
|
||||
|
||||
MD5_Init(&ctx);
|
||||
filestream_fseek(file, sizeof(header), SEEK_SET);
|
||||
filestream_seek(file, sizeof(header), SEEK_SET);
|
||||
/* from fceu core - check if Trainer included in ROM data */
|
||||
if (header.rom_type & 4)
|
||||
filestream_fseek(file, sizeof(header), SEEK_CUR);
|
||||
filestream_seek(file, sizeof(header), SEEK_CUR);
|
||||
|
||||
bytes = (round) ? rom_size : header.rom_size;
|
||||
num_read = filestream_fread(file, (void*) data, 0x4000 * bytes );
|
||||
filestream_fclose(file);
|
||||
num_read = filestream_read(file, (void*) data, 0x4000 * bytes );
|
||||
filestream_close(file);
|
||||
|
||||
if (num_read <= 0)
|
||||
return 0;
|
||||
|
@ -662,12 +662,12 @@ static void gx_efb_screenshot(void)
|
||||
{
|
||||
int x, y;
|
||||
uint8_t tga_header[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0xE0, 0x01, 0x18, 0x00};
|
||||
RFILE *out = filestream_fopen("/screenshot.tga", RFILE_MODE_WRITE, -1);
|
||||
RFILE *out = filestream_open("/screenshot.tga", RFILE_MODE_WRITE, -1);
|
||||
|
||||
if (!out)
|
||||
return;
|
||||
|
||||
filestream_fwrite(out, tga_header, sizeof(tga_header));
|
||||
filestream_write(out, tga_header, sizeof(tga_header));
|
||||
|
||||
for (y = 479; y >= 0; --y)
|
||||
{
|
||||
@ -682,10 +682,10 @@ static void gx_efb_screenshot(void)
|
||||
line[i++] = color.g;
|
||||
line[i++] = color.r;
|
||||
}
|
||||
filestream_fwrite(out, line, sizeof(line));
|
||||
filestream_write(out, line, sizeof(line));
|
||||
}
|
||||
|
||||
filestream_fclose(out);
|
||||
filestream_close(out);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -324,7 +324,7 @@ static void free_drm_resources(gfx_ctx_drm_data_t *drm)
|
||||
drm_free();
|
||||
|
||||
if (g_drm_fd >= 0)
|
||||
filestream_fclose(drm->drm);
|
||||
filestream_close(drm->drm);
|
||||
|
||||
g_gbm_surface = NULL;
|
||||
g_gbm_dev = NULL;
|
||||
@ -395,7 +395,7 @@ nextgpu:
|
||||
}
|
||||
gpu = gpu_descriptors->elems[gpu_index++].data;
|
||||
|
||||
drm->drm = filestream_fopen(gpu, RFILE_MODE_READ_WRITE, -1);
|
||||
drm->drm = filestream_open(gpu, RFILE_MODE_READ_WRITE, -1);
|
||||
if (!drm->drm)
|
||||
{
|
||||
RARCH_WARN("[KMS]: Couldn't open DRM device.\n");
|
||||
|
@ -65,12 +65,12 @@ static void gfx_ctx_mali_fbdev_destroy(void *data)
|
||||
}
|
||||
|
||||
/* Clear framebuffer and set cursor on again */
|
||||
fd = filestream_fopen("/dev/tty", RFILE_MODE_READ_WRITE, -1);
|
||||
fd = filestream_open("/dev/tty", RFILE_MODE_READ_WRITE, -1);
|
||||
fb = filestream_get_fd(fd);
|
||||
|
||||
ioctl(fb, VT_ACTIVATE,5);
|
||||
ioctl(fb, VT_ACTIVATE,1);
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
system("setterm -cursor on");
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data,
|
||||
EGL_NONE
|
||||
};
|
||||
mali_ctx_data_t *mali = (mali_ctx_data_t*)data;
|
||||
RFILE *fd = filestream_fopen("/dev/fb0", RFILE_MODE_READ_WRITE, -1);
|
||||
RFILE *fd = filestream_open("/dev/fb0", RFILE_MODE_READ_WRITE, -1);
|
||||
int fb = filestream_get_fd(fd);
|
||||
|
||||
if (ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) < 0)
|
||||
@ -190,7 +190,7 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data,
|
||||
goto error;
|
||||
}
|
||||
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
|
||||
width = vinfo.xres;
|
||||
height = vinfo.yres;
|
||||
@ -216,7 +216,7 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data,
|
||||
|
||||
error:
|
||||
if (fd)
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
RARCH_ERR("[Mali fbdev]: EGL error: %d.\n", eglGetError());
|
||||
gfx_ctx_mali_fbdev_destroy(data);
|
||||
return false;
|
||||
|
@ -105,7 +105,7 @@ static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool
|
||||
header[52] = 0;
|
||||
header[53] = 0;
|
||||
|
||||
return filestream_fwrite(file, header, sizeof(header)) == sizeof(header);
|
||||
return filestream_write(file, header, sizeof(header)) == sizeof(header);
|
||||
}
|
||||
|
||||
static void dump_line_565_to_24(uint8_t *line, const uint16_t *src, unsigned width)
|
||||
@ -161,9 +161,9 @@ static void dump_content(RFILE *file, const void *frame,
|
||||
int pad = line_size-pitch;
|
||||
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
||||
{
|
||||
filestream_fwrite(file, u.u8, pitch);
|
||||
filestream_write(file, u.u8, pitch);
|
||||
if(pad != 0)
|
||||
filestream_fwrite(file, &zeros, pad);
|
||||
filestream_write(file, &zeros, pad);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -171,7 +171,7 @@ static void dump_content(RFILE *file, const void *frame,
|
||||
{
|
||||
/* ARGB8888 byte order input matches output. Can directly copy. */
|
||||
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
||||
filestream_fwrite(file, u.u8, line_size);
|
||||
filestream_write(file, u.u8, line_size);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ static void dump_content(RFILE *file, const void *frame,
|
||||
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
||||
{
|
||||
dump_line_32_to_24(line, u.u32, width);
|
||||
filestream_fwrite(file, line, line_size);
|
||||
filestream_write(file, line, line_size);
|
||||
}
|
||||
}
|
||||
else /* type == RBMP_SOURCE_TYPE_RGB565 */
|
||||
@ -193,7 +193,7 @@ static void dump_content(RFILE *file, const void *frame,
|
||||
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
||||
{
|
||||
dump_line_565_to_24(line, u.u16, width);
|
||||
filestream_fwrite(file, line, line_size);
|
||||
filestream_write(file, line, line_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ bool rbmp_save_image(const char *filename, const void *frame,
|
||||
unsigned pitch, enum rbmp_source_type type)
|
||||
{
|
||||
bool ret;
|
||||
RFILE *file = filestream_fopen(filename, RFILE_MODE_WRITE, -1);
|
||||
RFILE *file = filestream_open(filename, RFILE_MODE_WRITE, -1);
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
@ -213,7 +213,7 @@ bool rbmp_save_image(const char *filename, const void *frame,
|
||||
if (ret)
|
||||
dump_content(file, frame, width, height, pitch, type);
|
||||
|
||||
filestream_fclose(file);
|
||||
filestream_close(file);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ static bool png_write_crc(RFILE *file, const uint8_t *data, size_t size)
|
||||
uint32_t crc = stream_backend->stream_crc_calculate(0, data, size);
|
||||
|
||||
dword_write_be(crc_raw, crc);
|
||||
return filestream_fwrite(file, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw);
|
||||
return filestream_write(file, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw);
|
||||
}
|
||||
|
||||
static bool png_write_ihdr(RFILE *file, const struct png_ihdr *ihdr)
|
||||
@ -85,7 +85,7 @@ static bool png_write_ihdr(RFILE *file, const struct png_ihdr *ihdr)
|
||||
dword_write_be(ihdr_raw + 0, sizeof(ihdr_raw) - 8);
|
||||
dword_write_be(ihdr_raw + 8, ihdr->width);
|
||||
dword_write_be(ihdr_raw + 12, ihdr->height);
|
||||
if (filestream_fwrite(file, ihdr_raw, sizeof(ihdr_raw)) != sizeof(ihdr_raw))
|
||||
if (filestream_write(file, ihdr_raw, sizeof(ihdr_raw)) != sizeof(ihdr_raw))
|
||||
return false;
|
||||
|
||||
if (!png_write_crc(file, ihdr_raw + sizeof(uint32_t),
|
||||
@ -97,7 +97,7 @@ static bool png_write_ihdr(RFILE *file, const struct png_ihdr *ihdr)
|
||||
|
||||
static bool png_write_idat(RFILE *file, const uint8_t *data, size_t size)
|
||||
{
|
||||
if (filestream_fwrite(file, data, size) != (ssize_t)size)
|
||||
if (filestream_write(file, data, size) != (ssize_t)size)
|
||||
return false;
|
||||
|
||||
if (!png_write_crc(file, data + sizeof(uint32_t), size - sizeof(uint32_t)))
|
||||
@ -113,7 +113,7 @@ static bool png_write_iend(RFILE *file)
|
||||
'I', 'E', 'N', 'D',
|
||||
};
|
||||
|
||||
if (filestream_fwrite(file, data, sizeof(data)) != sizeof(data))
|
||||
if (filestream_write(file, data, sizeof(data)) != sizeof(data))
|
||||
return false;
|
||||
|
||||
if (!png_write_crc(file, data + sizeof(uint32_t),
|
||||
@ -227,13 +227,13 @@ static bool rpng_save_image(const char *path,
|
||||
uint8_t *prev_encoded = NULL;
|
||||
uint8_t *encode_target = NULL;
|
||||
void *stream = NULL;
|
||||
RFILE *file = filestream_fopen(path, RFILE_MODE_WRITE, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
|
||||
if (!file)
|
||||
GOTO_END_ERROR();
|
||||
|
||||
stream_backend = file_archive_get_default_file_backend();
|
||||
|
||||
if (filestream_fwrite(file, png_magic, sizeof(png_magic)) != sizeof(png_magic))
|
||||
if (filestream_write(file, png_magic, sizeof(png_magic)) != sizeof(png_magic))
|
||||
GOTO_END_ERROR();
|
||||
|
||||
ihdr.width = width;
|
||||
@ -356,7 +356,7 @@ static bool rpng_save_image(const char *path,
|
||||
GOTO_END_ERROR();
|
||||
|
||||
end:
|
||||
filestream_fclose(file);
|
||||
filestream_close(file);
|
||||
free(encode_buf);
|
||||
free(deflate_buf);
|
||||
free(rgba_line);
|
||||
|
@ -418,7 +418,7 @@ rxml_document_t *rxml_load_document(const char *path)
|
||||
char *new_memory_buffer = NULL;
|
||||
const char *mem_ptr = NULL;
|
||||
long len = 0;
|
||||
RFILE *file = filestream_fopen(path, RFILE_MODE_READ, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
@ -426,19 +426,19 @@ rxml_document_t *rxml_load_document(const char *path)
|
||||
if (!doc)
|
||||
goto error;
|
||||
|
||||
filestream_fseek(file, 0, SEEK_END);
|
||||
len = filestream_ftell(file);
|
||||
filestream_frewind(file);
|
||||
filestream_seek(file, 0, SEEK_END);
|
||||
len = filestream_tell(file);
|
||||
filestream_rewind(file);
|
||||
|
||||
memory_buffer = (char*)malloc(len + 1);
|
||||
if (!memory_buffer)
|
||||
goto error;
|
||||
|
||||
memory_buffer[len] = '\0';
|
||||
if (filestream_fread(file, memory_buffer, len) != (size_t)len)
|
||||
if (filestream_read(file, memory_buffer, len) != (size_t)len)
|
||||
goto error;
|
||||
|
||||
filestream_fclose(file);
|
||||
filestream_close(file);
|
||||
file = NULL;
|
||||
|
||||
mem_ptr = memory_buffer;
|
||||
@ -462,7 +462,7 @@ rxml_document_t *rxml_load_document(const char *path)
|
||||
|
||||
error:
|
||||
free(memory_buffer);
|
||||
filestream_fclose(file);
|
||||
filestream_close(file);
|
||||
rxml_free_document(doc);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ int sha1_calculate(const char *path, char *result)
|
||||
unsigned char buff[4096] = {0};
|
||||
SHA1Context sha;
|
||||
int rv = 1;
|
||||
RFILE *fd = filestream_fopen(path, RFILE_MODE_READ, -1);
|
||||
RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
|
||||
if (!fd)
|
||||
goto error;
|
||||
@ -520,7 +520,7 @@ int sha1_calculate(const char *path, char *result)
|
||||
|
||||
do
|
||||
{
|
||||
rv = filestream_fread(fd, buff, 4096);
|
||||
rv = filestream_read(fd, buff, 4096);
|
||||
if (rv < 0)
|
||||
goto error;
|
||||
|
||||
@ -536,12 +536,12 @@ int sha1_calculate(const char *path, char *result)
|
||||
sha.Message_Digest[2],
|
||||
sha.Message_Digest[3], sha.Message_Digest[4]);
|
||||
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if (fd)
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -48,19 +48,19 @@ enum
|
||||
RFILE_HINT_MMAP = 1<<9 /* requires RFILE_MODE_READ */
|
||||
};
|
||||
|
||||
RFILE *filestream_fopen(const char *path, unsigned mode, ssize_t len);
|
||||
RFILE *filestream_open(const char *path, unsigned mode, ssize_t len);
|
||||
|
||||
ssize_t filestream_fseek(RFILE *stream, ssize_t offset, int whence);
|
||||
ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence);
|
||||
|
||||
ssize_t filestream_fread(RFILE *stream, void *s, size_t len);
|
||||
ssize_t filestream_read(RFILE *stream, void *data, size_t len);
|
||||
|
||||
ssize_t filestream_fwrite(RFILE *stream, const void *s, size_t len);
|
||||
ssize_t filestream_write(RFILE *stream, const void *data, size_t len);
|
||||
|
||||
ssize_t filestream_ftell(RFILE *stream);
|
||||
ssize_t filestream_tell(RFILE *stream);
|
||||
|
||||
void filestream_frewind(RFILE *stream);
|
||||
void filestream_rewind(RFILE *stream);
|
||||
|
||||
int filestream_fclose(RFILE *stream);
|
||||
int filestream_close(RFILE *stream);
|
||||
|
||||
int filestream_read_file(const char *path, void **buf, ssize_t *len);
|
||||
|
||||
|
@ -30,19 +30,19 @@ typedef struct memstream memstream_t;
|
||||
|
||||
memstream_t *memstream_open(void);
|
||||
|
||||
void memstream_close(memstream_t * stream);
|
||||
void memstream_close(memstream_t *stream);
|
||||
|
||||
size_t memstream_read(memstream_t * stream, void *data, size_t bytes);
|
||||
size_t memstream_read(memstream_t *stream, void *data, size_t bytes);
|
||||
|
||||
size_t memstream_write(memstream_t * stream, const void *data, size_t bytes);
|
||||
size_t memstream_write(memstream_t *stream, const void *data, size_t bytes);
|
||||
|
||||
int memstream_getc(memstream_t * stream);
|
||||
int memstream_getc(memstream_t *stream);
|
||||
|
||||
char *memstream_gets(memstream_t * stream, char *buffer, size_t len);
|
||||
char *memstream_gets(memstream_t *stream, char *buffer, size_t len);
|
||||
|
||||
size_t memstream_pos(memstream_t * stream);
|
||||
size_t memstream_pos(memstream_t *stream);
|
||||
|
||||
int memstream_seek(memstream_t * stream, int offset, int whence);
|
||||
int memstream_seek(memstream_t *stream, int offset, int whence);
|
||||
|
||||
void memstream_set_buffer(uint8_t *buffer, size_t size);
|
||||
|
||||
|
@ -105,7 +105,7 @@ int filestream_get_fd(RFILE *stream)
|
||||
#endif
|
||||
}
|
||||
|
||||
RFILE *filestream_fopen(const char *path, unsigned mode, ssize_t len)
|
||||
RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
|
||||
{
|
||||
int flags = 0;
|
||||
int mode_int = 0;
|
||||
@ -213,12 +213,12 @@ RFILE *filestream_fopen(const char *path, unsigned mode, ssize_t len)
|
||||
{
|
||||
stream->mappos = 0;
|
||||
stream->mapped = NULL;
|
||||
stream->mapsize = filestream_fseek(stream, 0, SEEK_END);
|
||||
stream->mapsize = filestream_seek(stream, 0, SEEK_END);
|
||||
|
||||
if (stream->mapsize == (uint64_t)-1)
|
||||
goto error;
|
||||
|
||||
filestream_frewind(stream);
|
||||
filestream_rewind(stream);
|
||||
|
||||
stream->mapped = (uint8_t*)mmap((void*)0, stream->mapsize, PROT_READ, MAP_SHARED, stream->fd, 0);
|
||||
|
||||
@ -237,11 +237,11 @@ RFILE *filestream_fopen(const char *path, unsigned mode, ssize_t len)
|
||||
return stream;
|
||||
|
||||
error:
|
||||
filestream_fclose(stream);
|
||||
filestream_close(stream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ssize_t filestream_fseek(RFILE *stream, ssize_t offset, int whence)
|
||||
ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence)
|
||||
{
|
||||
int ret = 0;
|
||||
if (!stream)
|
||||
@ -267,7 +267,7 @@ ssize_t filestream_fseek(RFILE *stream, ssize_t offset, int whence)
|
||||
#endif
|
||||
#ifdef HAVE_MMAP
|
||||
/* Need to check stream->mapped because this function is
|
||||
* called in filestream_fopen() */
|
||||
* called in filestream_open() */
|
||||
if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
|
||||
{
|
||||
/* fseek() returns error on under/overflow but allows cursor > EOF for
|
||||
@ -309,7 +309,7 @@ ssize_t filestream_fseek(RFILE *stream, ssize_t offset, int whence)
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t filestream_ftell(RFILE *stream)
|
||||
ssize_t filestream_tell(RFILE *stream)
|
||||
{
|
||||
if (!stream)
|
||||
return -1;
|
||||
@ -328,7 +328,7 @@ ssize_t filestream_ftell(RFILE *stream)
|
||||
#endif
|
||||
#ifdef HAVE_MMAP
|
||||
/* Need to check stream->mapped because this function
|
||||
* is called in filestream_fopen() */
|
||||
* is called in filestream_open() */
|
||||
if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
|
||||
return stream->mappos;
|
||||
else
|
||||
@ -337,12 +337,12 @@ ssize_t filestream_ftell(RFILE *stream)
|
||||
#endif
|
||||
}
|
||||
|
||||
void filestream_frewind(RFILE *stream)
|
||||
void filestream_rewind(RFILE *stream)
|
||||
{
|
||||
filestream_fseek(stream, 0L, SEEK_SET);
|
||||
filestream_seek(stream, 0L, SEEK_SET);
|
||||
}
|
||||
|
||||
ssize_t filestream_fread(RFILE *stream, void *s, size_t len)
|
||||
ssize_t filestream_read(RFILE *stream, void *s, size_t len)
|
||||
{
|
||||
if (!stream || !s)
|
||||
return -1;
|
||||
@ -379,7 +379,7 @@ ssize_t filestream_fread(RFILE *stream, void *s, size_t len)
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t filestream_fwrite(RFILE *stream, const void *s, size_t len)
|
||||
ssize_t filestream_write(RFILE *stream, const void *s, size_t len)
|
||||
{
|
||||
if (!stream)
|
||||
return -1;
|
||||
@ -405,7 +405,7 @@ ssize_t filestream_fwrite(RFILE *stream, const void *s, size_t len)
|
||||
#endif
|
||||
}
|
||||
|
||||
int filestream_fclose(RFILE *stream)
|
||||
int filestream_close(RFILE *stream)
|
||||
{
|
||||
if (!stream)
|
||||
return -1;
|
||||
@ -453,7 +453,7 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len)
|
||||
ssize_t ret = 0;
|
||||
ssize_t content_buf_size = 0;
|
||||
void *content_buf = NULL;
|
||||
RFILE *file = filestream_fopen(path, RFILE_MODE_READ, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
@ -465,21 +465,21 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (filestream_fseek(file, 0, SEEK_END) != 0)
|
||||
if (filestream_seek(file, 0, SEEK_END) != 0)
|
||||
goto error;
|
||||
|
||||
content_buf_size = filestream_ftell(file);
|
||||
content_buf_size = filestream_tell(file);
|
||||
if (content_buf_size < 0)
|
||||
goto error;
|
||||
|
||||
filestream_frewind(file);
|
||||
filestream_rewind(file);
|
||||
|
||||
content_buf = malloc(content_buf_size + 1);
|
||||
|
||||
if (!content_buf)
|
||||
goto error;
|
||||
|
||||
ret = filestream_fread(file, content_buf, content_buf_size);
|
||||
ret = filestream_read(file, content_buf, content_buf_size);
|
||||
if (ret < 0)
|
||||
{
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
@ -490,7 +490,7 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len)
|
||||
goto error;
|
||||
}
|
||||
|
||||
filestream_fclose(file);
|
||||
filestream_close(file);
|
||||
|
||||
*buf = content_buf;
|
||||
|
||||
@ -505,7 +505,7 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len)
|
||||
|
||||
error:
|
||||
if (file)
|
||||
filestream_fclose(file);
|
||||
filestream_close(file);
|
||||
if (content_buf)
|
||||
free(content_buf);
|
||||
if (len)
|
||||
@ -527,12 +527,12 @@ error:
|
||||
bool filestream_write_file(const char *path, const void *data, ssize_t size)
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
RFILE *file = filestream_fopen(path, RFILE_MODE_WRITE, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
ret = filestream_fwrite(file, data, size);
|
||||
filestream_fclose(file);
|
||||
ret = filestream_write(file, data, size);
|
||||
filestream_close(file);
|
||||
|
||||
return (ret == size);
|
||||
}
|
||||
|
@ -794,7 +794,7 @@ int main(int argc, char** argv)
|
||||
dat_buffer++;
|
||||
}
|
||||
|
||||
rdb_file = filestream_fopen(rdb_path, RFILE_MODE_WRITE, -1);
|
||||
rdb_file = filestream_open(rdb_path, RFILE_MODE_WRITE, -1);
|
||||
|
||||
if (!rdb_file)
|
||||
{
|
||||
@ -815,7 +815,7 @@ int main(int argc, char** argv)
|
||||
¤t_item);
|
||||
dat_converter_value_provider_free();
|
||||
|
||||
filestream_fclose(rdb_file);
|
||||
filestream_close(rdb_file);
|
||||
|
||||
dat_converter_list_free(dat_parser_list);
|
||||
|
||||
|
@ -142,14 +142,14 @@ 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_fseek(fd, 0, SEEK_CUR);
|
||||
ssize_t root = filestream_seek(fd, 0, SEEK_CUR);
|
||||
|
||||
memcpy(header.magic_number, MAGIC_NUMBER, sizeof(MAGIC_NUMBER)-1);
|
||||
|
||||
/* We write the header in the end because we need to know the size of
|
||||
* the db first */
|
||||
|
||||
filestream_fseek(fd, sizeof(libretrodb_header_t), SEEK_CUR);
|
||||
filestream_seek(fd, sizeof(libretrodb_header_t), SEEK_CUR);
|
||||
|
||||
item.type = RDT_NULL;
|
||||
while ((rv = value_provider(ctx, &item)) == 0)
|
||||
@ -171,11 +171,11 @@ int libretrodb_create(RFILE *fd, libretrodb_value_provider value_provider,
|
||||
if ((rv = rmsgpack_dom_write(fd, &sentinal)) < 0)
|
||||
goto clean;
|
||||
|
||||
header.metadata_offset = swap_if_little64(filestream_fseek(fd, 0, SEEK_CUR));
|
||||
header.metadata_offset = swap_if_little64(filestream_seek(fd, 0, SEEK_CUR));
|
||||
md.count = item_count;
|
||||
libretrodb_write_metadata(fd, &md);
|
||||
filestream_fseek(fd, root, SEEK_SET);
|
||||
filestream_fwrite(fd, &header, sizeof(header));
|
||||
filestream_seek(fd, root, SEEK_SET);
|
||||
filestream_write(fd, &header, sizeof(header));
|
||||
clean:
|
||||
rmsgpack_dom_value_free(&item);
|
||||
return rv;
|
||||
@ -204,7 +204,7 @@ static void libretrodb_write_index_header(RFILE *fd, libretrodb_index_t *idx)
|
||||
void libretrodb_close(libretrodb_t *db)
|
||||
{
|
||||
if (db->fd)
|
||||
filestream_fclose(db->fd);
|
||||
filestream_close(db->fd);
|
||||
db->fd = NULL;
|
||||
}
|
||||
|
||||
@ -213,15 +213,15 @@ int libretrodb_open(const char *path, libretrodb_t *db)
|
||||
libretrodb_header_t header;
|
||||
libretrodb_metadata_t md;
|
||||
int rv;
|
||||
RFILE *fd = filestream_fopen(path, RFILE_MODE_READ, -1);
|
||||
RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
|
||||
if (!fd)
|
||||
return -errno;
|
||||
|
||||
strlcpy(db->path, path, sizeof(db->path));
|
||||
db->root = filestream_fseek(fd, 0, SEEK_CUR);
|
||||
db->root = filestream_seek(fd, 0, SEEK_CUR);
|
||||
|
||||
if ((rv = filestream_fread(fd, &header, sizeof(header))) == -1)
|
||||
if ((rv = filestream_read(fd, &header, sizeof(header))) == -1)
|
||||
{
|
||||
rv = -errno;
|
||||
goto error;
|
||||
@ -234,7 +234,7 @@ int libretrodb_open(const char *path, libretrodb_t *db)
|
||||
}
|
||||
|
||||
header.metadata_offset = swap_if_little64(header.metadata_offset);
|
||||
filestream_fseek(fd, (ssize_t)header.metadata_offset, SEEK_SET);
|
||||
filestream_seek(fd, (ssize_t)header.metadata_offset, SEEK_SET);
|
||||
|
||||
if (libretrodb_read_metadata(fd, &md) < 0)
|
||||
{
|
||||
@ -243,21 +243,21 @@ int libretrodb_open(const char *path, libretrodb_t *db)
|
||||
}
|
||||
|
||||
db->count = md.count;
|
||||
db->first_index_offset = filestream_fseek(fd, 0, SEEK_CUR);
|
||||
db->first_index_offset = filestream_seek(fd, 0, SEEK_CUR);
|
||||
db->fd = fd;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if (fd)
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int libretrodb_find_index(libretrodb_t *db, const char *index_name,
|
||||
libretrodb_index_t *idx)
|
||||
{
|
||||
ssize_t eof = filestream_fseek(db->fd, 0, SEEK_END);
|
||||
ssize_t offset = filestream_fseek(db->fd,
|
||||
ssize_t eof = filestream_seek(db->fd, 0, SEEK_END);
|
||||
ssize_t offset = filestream_seek(db->fd,
|
||||
(ssize_t)db->first_index_offset, SEEK_SET);
|
||||
|
||||
while (offset < eof)
|
||||
@ -267,7 +267,7 @@ 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_fseek(db->fd, (ssize_t)idx->next, SEEK_CUR);
|
||||
offset = filestream_seek(db->fd, (ssize_t)idx->next, SEEK_CUR);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -323,7 +323,7 @@ int libretrodb_find_entry(libretrodb_t *db, const char *index_name,
|
||||
while (nread < bufflen)
|
||||
{
|
||||
void *buff_ = (uint64_t *)buff + nread;
|
||||
rv = filestream_fread(db->fd, buff_, bufflen - nread);
|
||||
rv = filestream_read(db->fd, buff_, bufflen - nread);
|
||||
|
||||
if (rv <= 0)
|
||||
{
|
||||
@ -337,7 +337,7 @@ int libretrodb_find_entry(libretrodb_t *db, const char *index_name,
|
||||
free(buff);
|
||||
|
||||
if (rv == 0)
|
||||
filestream_fseek(db->fd, (ssize_t)offset, SEEK_SET);
|
||||
filestream_seek(db->fd, (ssize_t)offset, SEEK_SET);
|
||||
|
||||
return rmsgpack_dom_read(db->fd, out);
|
||||
}
|
||||
@ -353,7 +353,7 @@ int libretrodb_find_entry(libretrodb_t *db, const char *index_name,
|
||||
int libretrodb_cursor_reset(libretrodb_cursor_t *cursor)
|
||||
{
|
||||
cursor->eof = 0;
|
||||
return filestream_fseek(cursor->fd,
|
||||
return filestream_seek(cursor->fd,
|
||||
(ssize_t)(cursor->db->root + sizeof(libretrodb_header_t)),
|
||||
SEEK_SET);
|
||||
}
|
||||
@ -401,7 +401,7 @@ void libretrodb_cursor_close(libretrodb_cursor_t *cursor)
|
||||
return;
|
||||
|
||||
if (cursor->fd)
|
||||
filestream_fclose(cursor->fd);
|
||||
filestream_close(cursor->fd);
|
||||
|
||||
if (cursor->query)
|
||||
libretrodb_query_free(cursor->query);
|
||||
@ -426,7 +426,7 @@ void libretrodb_cursor_close(libretrodb_cursor_t *cursor)
|
||||
int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor,
|
||||
libretrodb_query_t *q)
|
||||
{
|
||||
cursor->fd = filestream_fopen(db->path, RFILE_MODE_READ | RFILE_HINT_MMAP, -1);
|
||||
cursor->fd = filestream_open(db->path, RFILE_MODE_READ | RFILE_HINT_MMAP, -1);
|
||||
|
||||
if (!cursor->fd)
|
||||
return -errno;
|
||||
@ -446,7 +446,7 @@ static int node_iter(void *value, void *ctx)
|
||||
{
|
||||
struct node_iter_ctx *nictx = (struct node_iter_ctx*)ctx;
|
||||
|
||||
if (filestream_fwrite(nictx->db->fd, value,
|
||||
if (filestream_write(nictx->db->fd, value,
|
||||
(ssize_t)(nictx->idx->key_size + sizeof(uint64_t))) > 0)
|
||||
return 0;
|
||||
|
||||
@ -455,7 +455,7 @@ static int node_iter(void *value, void *ctx)
|
||||
|
||||
static uint64_t libretrodb_tell(libretrodb_t *db)
|
||||
{
|
||||
return filestream_fseek(db->fd, 0, SEEK_CUR);
|
||||
return filestream_seek(db->fd, 0, SEEK_CUR);
|
||||
}
|
||||
|
||||
int libretrodb_create_index(libretrodb_t *db,
|
||||
@ -554,7 +554,7 @@ int libretrodb_create_index(libretrodb_t *db,
|
||||
item_loc = libretrodb_tell(db);
|
||||
}
|
||||
|
||||
idx_header_offset = filestream_fseek(db->fd, 0, SEEK_END);
|
||||
idx_header_offset = filestream_seek(db->fd, 0, SEEK_END);
|
||||
|
||||
(void)idx_header_offset;
|
||||
(void)rv;
|
||||
|
@ -92,7 +92,7 @@ int main(int argc, char ** argv)
|
||||
|
||||
call_init(L, argc - 2, (const char **) argv + 2);
|
||||
|
||||
dst = filestream_fopen(db_file, RFILE_MODE_WRITE, -1);
|
||||
dst = filestream_open(db_file, RFILE_MODE_WRITE, -1);
|
||||
if (!dst)
|
||||
{
|
||||
printf(
|
||||
@ -108,6 +108,6 @@ int main(int argc, char ** argv)
|
||||
|
||||
clean:
|
||||
lua_close(L);
|
||||
filestream_fclose(dst);
|
||||
filestream_close(dst);
|
||||
return rv;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ static int create_db(lua_State *L)
|
||||
}
|
||||
lua_setfield(L, LUA_REGISTRYINDEX, "testlib_get_value");
|
||||
|
||||
dst = filestream_fopen(db_file, RFILE_MODE_WRITE, -1);
|
||||
dst = filestream_open(db_file, RFILE_MODE_WRITE, -1);
|
||||
if (!dst)
|
||||
{
|
||||
lua_pushstring(L, "Could not open destination file");
|
||||
@ -114,7 +114,7 @@ static int create_db(lua_State *L)
|
||||
}
|
||||
|
||||
libretrodb_create(dst, &value_provider, L);
|
||||
filestream_fclose(dst);
|
||||
filestream_close(dst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -106,26 +106,26 @@ int rmsgpack_write_array_header(RFILE *fd, uint32_t size)
|
||||
if (size < 16)
|
||||
{
|
||||
size = (size | MPF_FIXARRAY);
|
||||
if (filestream_fwrite(fd, &size, sizeof(int8_t)) == -1)
|
||||
if (filestream_write(fd, &size, sizeof(int8_t)) == -1)
|
||||
goto error;
|
||||
return sizeof(int8_t);
|
||||
}
|
||||
else if (size == (uint16_t)size)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_ARRAY16, sizeof(MPF_ARRAY16)) == -1)
|
||||
if (filestream_write(fd, &MPF_ARRAY16, sizeof(MPF_ARRAY16)) == -1)
|
||||
goto error;
|
||||
tmp_i16 = swap_if_little16(size);
|
||||
if (filestream_fwrite(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1)
|
||||
if (filestream_write(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
return sizeof(int8_t) + sizeof(uint16_t);
|
||||
}
|
||||
|
||||
if (filestream_fwrite(fd, &MPF_ARRAY32, sizeof(MPF_ARRAY32)) == -1)
|
||||
if (filestream_write(fd, &MPF_ARRAY32, sizeof(MPF_ARRAY32)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i32 = swap_if_little32(size);
|
||||
|
||||
if (filestream_fwrite(fd, (void *)(&tmp_i32), sizeof(uint32_t)) == -1)
|
||||
if (filestream_write(fd, (void *)(&tmp_i32), sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
|
||||
return sizeof(int8_t) + sizeof(uint32_t);
|
||||
@ -142,24 +142,24 @@ int rmsgpack_write_map_header(RFILE *fd, uint32_t size)
|
||||
if (size < 16)
|
||||
{
|
||||
size = (size | MPF_FIXMAP);
|
||||
if (filestream_fwrite(fd, &size, sizeof(int8_t)) == -1)
|
||||
if (filestream_write(fd, &size, sizeof(int8_t)) == -1)
|
||||
goto error;
|
||||
return sizeof(int8_t);
|
||||
}
|
||||
else if (size < (uint16_t)size)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_MAP16, sizeof(MPF_MAP16)) == -1)
|
||||
if (filestream_write(fd, &MPF_MAP16, sizeof(MPF_MAP16)) == -1)
|
||||
goto error;
|
||||
tmp_i16 = swap_if_little16(size);
|
||||
if (filestream_fwrite(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1)
|
||||
if (filestream_write(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
return sizeof(uint8_t) + sizeof(uint16_t);
|
||||
}
|
||||
|
||||
tmp_i32 = swap_if_little32(size);
|
||||
if (filestream_fwrite(fd, &MPF_MAP32, sizeof(MPF_MAP32)) == -1)
|
||||
if (filestream_write(fd, &MPF_MAP32, sizeof(MPF_MAP32)) == -1)
|
||||
goto error;
|
||||
if (filestream_fwrite(fd, (void *)(&tmp_i32), sizeof(uint32_t)) == -1)
|
||||
if (filestream_write(fd, (void *)(&tmp_i32), sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
|
||||
return sizeof(int8_t) + sizeof(uint32_t);
|
||||
@ -178,37 +178,37 @@ int rmsgpack_write_string(RFILE *fd, const char *s, uint32_t len)
|
||||
if (len < 32)
|
||||
{
|
||||
fixlen = len | MPF_FIXSTR;
|
||||
if (filestream_fwrite(fd, &fixlen, sizeof(int8_t)) == -1)
|
||||
if (filestream_write(fd, &fixlen, sizeof(int8_t)) == -1)
|
||||
goto error;
|
||||
}
|
||||
else if (len < (1 << 8))
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_STR8, sizeof(MPF_STR8)) == -1)
|
||||
if (filestream_write(fd, &MPF_STR8, sizeof(MPF_STR8)) == -1)
|
||||
goto error;
|
||||
if (filestream_fwrite(fd, &len, sizeof(uint8_t)) == -1)
|
||||
if (filestream_write(fd, &len, sizeof(uint8_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint8_t);
|
||||
}
|
||||
else if (len < (1 << 16))
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_STR16, sizeof(MPF_STR16)) == -1)
|
||||
if (filestream_write(fd, &MPF_STR16, sizeof(MPF_STR16)) == -1)
|
||||
goto error;
|
||||
tmp_i16 = swap_if_little16(len);
|
||||
if (filestream_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
if (filestream_write(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint16_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_STR32, sizeof(MPF_STR32)) == -1)
|
||||
if (filestream_write(fd, &MPF_STR32, sizeof(MPF_STR32)) == -1)
|
||||
goto error;
|
||||
tmp_i32 = swap_if_little32(len);
|
||||
if (filestream_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
if (filestream_write(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint32_t);
|
||||
}
|
||||
|
||||
if (filestream_fwrite(fd, s, len) == -1)
|
||||
if (filestream_write(fd, s, len) == -1)
|
||||
goto error;
|
||||
|
||||
written += len;
|
||||
@ -227,31 +227,31 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len)
|
||||
|
||||
if (len == (uint8_t)len)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_BIN8, sizeof(MPF_BIN8)) == -1)
|
||||
if (filestream_write(fd, &MPF_BIN8, sizeof(MPF_BIN8)) == -1)
|
||||
goto error;
|
||||
if (filestream_fwrite(fd, &len, sizeof(uint8_t)) == -1)
|
||||
if (filestream_write(fd, &len, sizeof(uint8_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint8_t);
|
||||
}
|
||||
else if (len == (uint16_t)len)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_BIN16, sizeof(MPF_BIN16)) == -1)
|
||||
if (filestream_write(fd, &MPF_BIN16, sizeof(MPF_BIN16)) == -1)
|
||||
goto error;
|
||||
tmp_i16 = swap_if_little16(len);
|
||||
if (filestream_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
if (filestream_write(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint16_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_BIN32, sizeof(MPF_BIN32)) == -1)
|
||||
if (filestream_write(fd, &MPF_BIN32, sizeof(MPF_BIN32)) == -1)
|
||||
goto error;
|
||||
tmp_i32 = swap_if_little32(len);
|
||||
if (filestream_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
if (filestream_write(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint32_t);
|
||||
}
|
||||
if (filestream_fwrite(fd, s, len) == -1)
|
||||
if (filestream_write(fd, s, len) == -1)
|
||||
goto error;
|
||||
|
||||
written += len;
|
||||
@ -264,7 +264,7 @@ error:
|
||||
|
||||
int rmsgpack_write_nil(RFILE *fd)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_NIL, sizeof(MPF_NIL)) == -1)
|
||||
if (filestream_write(fd, &MPF_NIL, sizeof(MPF_NIL)) == -1)
|
||||
return -errno;
|
||||
return sizeof(uint8_t);
|
||||
}
|
||||
@ -273,11 +273,11 @@ int rmsgpack_write_bool(RFILE *fd, int value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_TRUE, sizeof(MPF_TRUE)) == -1)
|
||||
if (filestream_write(fd, &MPF_TRUE, sizeof(MPF_TRUE)) == -1)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (filestream_fwrite(fd, &MPF_FALSE, sizeof(MPF_FALSE)) == -1)
|
||||
if (filestream_write(fd, &MPF_FALSE, sizeof(MPF_FALSE)) == -1)
|
||||
goto error;
|
||||
|
||||
return sizeof(uint8_t);
|
||||
@ -295,51 +295,51 @@ int rmsgpack_write_int(RFILE *fd, int64_t value)
|
||||
|
||||
if (value >=0 && value < 128)
|
||||
{
|
||||
if (filestream_fwrite(fd, &value, sizeof(int8_t)) == -1)
|
||||
if (filestream_write(fd, &value, sizeof(int8_t)) == -1)
|
||||
goto error;
|
||||
}
|
||||
else if (value < 0 && value > -32)
|
||||
{
|
||||
tmpval = (value) | 0xe0;
|
||||
if (filestream_fwrite(fd, &tmpval, sizeof(uint8_t)) == -1)
|
||||
if (filestream_write(fd, &tmpval, sizeof(uint8_t)) == -1)
|
||||
goto error;
|
||||
}
|
||||
else if (value == (int8_t)value)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_INT8, sizeof(MPF_INT8)) == -1)
|
||||
if (filestream_write(fd, &MPF_INT8, sizeof(MPF_INT8)) == -1)
|
||||
goto error;
|
||||
|
||||
if (filestream_fwrite(fd, &value, sizeof(int8_t)) == -1)
|
||||
if (filestream_write(fd, &value, sizeof(int8_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(int8_t);
|
||||
}
|
||||
else if (value == (int16_t)value)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_INT16, sizeof(MPF_INT16)) == -1)
|
||||
if (filestream_write(fd, &MPF_INT16, sizeof(MPF_INT16)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i16 = swap_if_little16((uint16_t)value);
|
||||
if (filestream_fwrite(fd, &tmp_i16, sizeof(int16_t)) == -1)
|
||||
if (filestream_write(fd, &tmp_i16, sizeof(int16_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(int16_t);
|
||||
}
|
||||
else if (value == (int32_t)value)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_INT32, sizeof(MPF_INT32)) == -1)
|
||||
if (filestream_write(fd, &MPF_INT32, sizeof(MPF_INT32)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i32 = swap_if_little32((uint32_t)value);
|
||||
if (filestream_fwrite(fd, &tmp_i32, sizeof(int32_t)) == -1)
|
||||
if (filestream_write(fd, &tmp_i32, sizeof(int32_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(int32_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_INT64, sizeof(MPF_INT64)) == -1)
|
||||
if (filestream_write(fd, &MPF_INT64, sizeof(MPF_INT64)) == -1)
|
||||
goto error;
|
||||
|
||||
value = swap_if_little64(value);
|
||||
if (filestream_fwrite(fd, &value, sizeof(int64_t)) == -1)
|
||||
if (filestream_write(fd, &value, sizeof(int64_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(int64_t);
|
||||
}
|
||||
@ -358,40 +358,40 @@ int rmsgpack_write_uint(RFILE *fd, uint64_t value)
|
||||
|
||||
if (value == (uint8_t)value)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_UINT8, sizeof(MPF_UINT8)) == -1)
|
||||
if (filestream_write(fd, &MPF_UINT8, sizeof(MPF_UINT8)) == -1)
|
||||
goto error;
|
||||
|
||||
if (filestream_fwrite(fd, &value, sizeof(uint8_t)) == -1)
|
||||
if (filestream_write(fd, &value, sizeof(uint8_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint8_t);
|
||||
}
|
||||
else if (value == (uint16_t)value)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_UINT16, sizeof(MPF_UINT16)) == -1)
|
||||
if (filestream_write(fd, &MPF_UINT16, sizeof(MPF_UINT16)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i16 = swap_if_little16((uint16_t)value);
|
||||
if (filestream_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
if (filestream_write(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint16_t);
|
||||
}
|
||||
else if (value == (uint32_t)value)
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_UINT32, sizeof(MPF_UINT32)) == -1)
|
||||
if (filestream_write(fd, &MPF_UINT32, sizeof(MPF_UINT32)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i32 = swap_if_little32((uint32_t)value);
|
||||
if (filestream_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
if (filestream_write(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint32_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (filestream_fwrite(fd, &MPF_UINT64, sizeof(MPF_UINT64)) == -1)
|
||||
if (filestream_write(fd, &MPF_UINT64, sizeof(MPF_UINT64)) == -1)
|
||||
goto error;
|
||||
|
||||
value = swap_if_little64(value);
|
||||
if (filestream_fwrite(fd, &value, sizeof(uint64_t)) == -1)
|
||||
if (filestream_write(fd, &value, sizeof(uint64_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint64_t);
|
||||
}
|
||||
@ -405,7 +405,7 @@ static int read_uint(RFILE *fd, uint64_t *out, size_t size)
|
||||
{
|
||||
uint64_t tmp;
|
||||
|
||||
if (filestream_fread(fd, &tmp, size) == -1)
|
||||
if (filestream_read(fd, &tmp, size) == -1)
|
||||
goto error;
|
||||
|
||||
switch (size)
|
||||
@ -436,7 +436,7 @@ static int read_int(RFILE *fd, int64_t *out, size_t size)
|
||||
uint32_t tmp32;
|
||||
uint64_t tmp64;
|
||||
|
||||
if (filestream_fread(fd, &tmp64, size) == -1)
|
||||
if (filestream_read(fd, &tmp64, size) == -1)
|
||||
goto error;
|
||||
|
||||
(void)tmp8;
|
||||
@ -475,7 +475,7 @@ static int read_buff(RFILE *fd, size_t size, char **pbuff, uint64_t *len)
|
||||
|
||||
*pbuff = (char *)malloc((size_t)(tmp_len + 1) * sizeof(char));
|
||||
|
||||
if ((read_len = filestream_fread(fd, *pbuff, (size_t)tmp_len)) == -1)
|
||||
if ((read_len = filestream_read(fd, *pbuff, (size_t)tmp_len)) == -1)
|
||||
goto error;
|
||||
|
||||
*len = read_len;
|
||||
@ -540,7 +540,7 @@ int rmsgpack_read(RFILE *fd,
|
||||
uint8_t type = 0;
|
||||
char *buff = NULL;
|
||||
|
||||
if (filestream_fread(fd, &type, sizeof(uint8_t)) == -1)
|
||||
if (filestream_read(fd, &type, sizeof(uint8_t)) == -1)
|
||||
goto error;
|
||||
|
||||
if (type < MPF_FIXMAP)
|
||||
@ -566,7 +566,7 @@ int rmsgpack_read(RFILE *fd,
|
||||
buff = (char *)malloc((size_t)(tmp_len + 1) * sizeof(char));
|
||||
if (!buff)
|
||||
return -ENOMEM;
|
||||
if ((read_len = filestream_fread(fd, buff, (ssize_t)tmp_len)) == -1)
|
||||
if ((read_len = filestream_read(fd, buff, (ssize_t)tmp_len)) == -1)
|
||||
{
|
||||
free(buff);
|
||||
goto error;
|
||||
|
@ -186,7 +186,7 @@ static struct rmsgpack_read_callbacks stub_callbacks = {
|
||||
int main(void)
|
||||
{
|
||||
struct stub_state state;
|
||||
RFILE *fd = filestream_fopen("test.msgpack", RFILE_MODE_READ, 0);
|
||||
RFILE *fd = filestream_open("test.msgpack", RFILE_MODE_READ, 0);
|
||||
|
||||
state.i = 0;
|
||||
state.stack[0] = 0;
|
||||
@ -194,7 +194,7 @@ int main(void)
|
||||
rmsgpack_read(fd, &stub_callbacks, &state);
|
||||
|
||||
printf("Test succeeded.\n");
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -181,14 +181,14 @@ static bool menu_content_load_from_playlist(void *data)
|
||||
|
||||
free(path_tolower);
|
||||
|
||||
fp = filestream_fopen(path_check, RFILE_MODE_READ, -1);
|
||||
fp = filestream_open(path_check, RFILE_MODE_READ, -1);
|
||||
|
||||
free(path_check);
|
||||
|
||||
if (!fp)
|
||||
goto error;
|
||||
|
||||
filestream_fclose(fp);
|
||||
filestream_close(fp);
|
||||
}
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path);
|
||||
|
@ -65,7 +65,7 @@ static ssize_t get_token(RFILE *fd, char *token, size_t max_len)
|
||||
|
||||
while (1)
|
||||
{
|
||||
int rv = filestream_fread(fd, c, 1);
|
||||
int rv = filestream_read(fd, c, 1);
|
||||
if (rv == 0)
|
||||
return 0;
|
||||
|
||||
@ -143,21 +143,21 @@ static int detect_ps1_game_sub(const char *track_path,
|
||||
uint8_t* tmp;
|
||||
uint8_t buffer[2048 * 2];
|
||||
int skip, frame_size, is_mode1, cd_sector;
|
||||
RFILE *fp = filestream_fopen(track_path, RFILE_MODE_READ, -1);
|
||||
RFILE *fp = filestream_open(track_path, RFILE_MODE_READ, -1);
|
||||
if (!fp)
|
||||
return 0;
|
||||
|
||||
is_mode1 = 0;
|
||||
filestream_fseek(fp, 0, SEEK_END);
|
||||
filestream_seek(fp, 0, SEEK_END);
|
||||
|
||||
if (!sub_channel_mixed)
|
||||
{
|
||||
if (!(filestream_ftell(fp) & 0x7FF))
|
||||
if (!(filestream_tell(fp) & 0x7FF))
|
||||
{
|
||||
unsigned int mode_test = 0;
|
||||
|
||||
filestream_fseek(fp, 0, SEEK_SET);
|
||||
filestream_fread(fp, &mode_test, 4);
|
||||
filestream_seek(fp, 0, SEEK_SET);
|
||||
filestream_read(fp, &mode_test, 4);
|
||||
if (mode_test != MODETEST_VAL)
|
||||
is_mode1 = 1;
|
||||
}
|
||||
@ -166,12 +166,12 @@ static int detect_ps1_game_sub(const char *track_path,
|
||||
skip = is_mode1? 0: 24;
|
||||
frame_size = sub_channel_mixed? 2448: is_mode1? 2048: 2352;
|
||||
|
||||
filestream_fseek(fp, 156 + skip + 16 * frame_size, SEEK_SET);
|
||||
filestream_fread(fp, buffer, 6);
|
||||
filestream_seek(fp, 156 + skip + 16 * frame_size, SEEK_SET);
|
||||
filestream_read(fp, buffer, 6);
|
||||
|
||||
cd_sector = buffer[2] | (buffer[3] << 8) | (buffer[4] << 16);
|
||||
filestream_fseek(fp, skip + cd_sector * frame_size, SEEK_SET);
|
||||
filestream_fread(fp, buffer, 2048 * 2);
|
||||
filestream_seek(fp, skip + cd_sector * frame_size, SEEK_SET);
|
||||
filestream_read(fp, buffer, 2048 * 2);
|
||||
|
||||
tmp = buffer;
|
||||
while (tmp < (buffer + 2048 * 2))
|
||||
@ -188,8 +188,8 @@ static int detect_ps1_game_sub(const char *track_path,
|
||||
return 0;
|
||||
|
||||
cd_sector = tmp[2] | (tmp[3] << 8) | (tmp[4] << 16);
|
||||
filestream_fseek(fp, 13 + skip + cd_sector * frame_size, SEEK_SET);
|
||||
filestream_fread(fp, buffer, 256);
|
||||
filestream_seek(fp, 13 + skip + cd_sector * frame_size, SEEK_SET);
|
||||
filestream_read(fp, buffer, 256);
|
||||
|
||||
tmp = (uint8_t*)strrchr((const char*)buffer, '\\');
|
||||
if(!tmp)
|
||||
@ -211,7 +211,7 @@ static int detect_ps1_game_sub(const char *track_path,
|
||||
*game_id++ = *tmp++;
|
||||
*game_id = 0;
|
||||
|
||||
filestream_fclose(fp);
|
||||
filestream_close(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ int detect_psp_game(const char *track_path, char *game_id)
|
||||
{
|
||||
unsigned pos;
|
||||
bool rv = false;
|
||||
RFILE *fd = filestream_fopen(track_path, RFILE_MODE_READ, -1);
|
||||
RFILE *fd = filestream_open(track_path, RFILE_MODE_READ, -1);
|
||||
|
||||
if (!fd)
|
||||
{
|
||||
@ -237,9 +237,9 @@ int detect_psp_game(const char *track_path, char *game_id)
|
||||
|
||||
for (pos = 0; pos < 100000; pos++)
|
||||
{
|
||||
filestream_fseek(fd, pos, SEEK_SET);
|
||||
filestream_seek(fd, pos, SEEK_SET);
|
||||
|
||||
if (filestream_fread(fd, game_id, 5) > 0)
|
||||
if (filestream_read(fd, game_id, 5) > 0)
|
||||
{
|
||||
game_id[5] = '\0';
|
||||
if (string_is_equal(game_id, "ULES-")
|
||||
@ -269,8 +269,8 @@ int detect_psp_game(const char *track_path, char *game_id)
|
||||
|| string_is_equal(game_id, "NPJZ-")
|
||||
)
|
||||
{
|
||||
filestream_fseek(fd, pos, SEEK_SET);
|
||||
if (filestream_fread(fd, game_id, 10) > 0)
|
||||
filestream_seek(fd, pos, SEEK_SET);
|
||||
if (filestream_read(fd, game_id, 10) > 0)
|
||||
{
|
||||
#if 0
|
||||
game_id[4] = '-';
|
||||
@ -287,7 +287,7 @@ int detect_psp_game(const char *track_path, char *game_id)
|
||||
break;
|
||||
}
|
||||
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ int detect_system(const char *track_path, int32_t offset,
|
||||
int rv;
|
||||
char magic[MAGIC_LEN];
|
||||
int i;
|
||||
RFILE *fd = filestream_fopen(track_path, RFILE_MODE_READ, -1);
|
||||
RFILE *fd = filestream_open(track_path, RFILE_MODE_READ, -1);
|
||||
|
||||
if (!fd)
|
||||
{
|
||||
@ -307,8 +307,8 @@ int detect_system(const char *track_path, int32_t offset,
|
||||
goto clean;
|
||||
}
|
||||
|
||||
filestream_fseek(fd, offset, SEEK_SET);
|
||||
if (filestream_fread(fd, magic, MAGIC_LEN) < MAGIC_LEN)
|
||||
filestream_seek(fd, offset, SEEK_SET);
|
||||
if (filestream_read(fd, magic, MAGIC_LEN) < MAGIC_LEN)
|
||||
{
|
||||
RARCH_LOG("Could not read data from file '%s' at offset %d: %s\n",
|
||||
track_path, offset, strerror(errno));
|
||||
@ -327,8 +327,8 @@ int detect_system(const char *track_path, int32_t offset,
|
||||
}
|
||||
}
|
||||
|
||||
filestream_fseek(fd, 0x8008, SEEK_SET);
|
||||
if (filestream_fread(fd, magic, 8) > 0)
|
||||
filestream_seek(fd, 0x8008, SEEK_SET);
|
||||
if (filestream_read(fd, magic, 8) > 0)
|
||||
{
|
||||
magic[8] = '\0';
|
||||
if (string_is_equal(magic, "PSP GAME"))
|
||||
@ -342,7 +342,7 @@ int detect_system(const char *track_path, int32_t offset,
|
||||
RARCH_LOG("Could not find compatible system\n");
|
||||
rv = -EINVAL;
|
||||
clean:
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ int find_first_data_track(const char *cue_path,
|
||||
strlcpy(cue_dir, cue_path, sizeof(cue_dir));
|
||||
path_basedir(cue_dir);
|
||||
|
||||
fd = filestream_fopen(cue_path, RFILE_MODE_READ, -1);
|
||||
fd = filestream_open(cue_path, RFILE_MODE_READ, -1);
|
||||
if (!fd)
|
||||
{
|
||||
RARCH_LOG("Could not open CUE file '%s': %s\n", cue_path,
|
||||
@ -405,6 +405,6 @@ int find_first_data_track(const char *cue_path,
|
||||
rv = -EINVAL;
|
||||
|
||||
clean:
|
||||
filestream_fclose(fd);
|
||||
filestream_close(fd);
|
||||
return rv;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user