diff --git a/cheevos.c b/cheevos.c index 82586cdb09a..d700f9ee3b1 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1688,7 +1688,7 @@ static size_t cheevos_eval_md5( } else { - RFILE *file = retro_fopen(info->path, RFILE_MODE_READ, 0); + RFILE *file = filestream_fopen(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 = retro_fread(file, + ssize_t num_read = filestream_fread(file, (void*)buffer, sizeof(buffer)); if (num_read <= 0) @@ -1707,7 +1707,7 @@ static size_t cheevos_eval_md5( size += num_read; } - retro_fclose(file); + filestream_fclose(file); return size; } } @@ -1825,14 +1825,14 @@ static unsigned cheevos_find_game_id_nes( } else { - RFILE *file = retro_fopen(info->path, RFILE_MODE_READ, 0); + RFILE *file = filestream_fopen(info->path, RFILE_MODE_READ, 0); ssize_t num_read; if (!file) return 0; - num_read = retro_fread(file, (void*)&header, sizeof(header)); - retro_fclose(file); + num_read = filestream_fread(file, (void*)&header, sizeof(header)); + filestream_fclose(file); if (num_read < (ssize_t)sizeof(header)) return 0; @@ -1868,8 +1868,8 @@ static unsigned cheevos_find_game_id_nes( { 53, 198, 228 }; - bool round = true; - RFILE *file = retro_fopen(info->path, RFILE_MODE_READ, 0); + bool round = true; + RFILE *file = filestream_fopen(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); - retro_fseek(file, sizeof(header), SEEK_SET); + filestream_fseek(file, sizeof(header), SEEK_SET); /* from fceu core - check if Trainer included in ROM data */ if (header.rom_type & 4) - retro_fseek(file, sizeof(header), SEEK_CUR); + filestream_fseek(file, sizeof(header), SEEK_CUR); bytes = (round) ? rom_size : header.rom_size; - num_read = retro_fread(file, (void*) data, 0x4000 * bytes ); - retro_fclose(file); + num_read = filestream_fread(file, (void*) data, 0x4000 * bytes ); + filestream_fclose(file); if (num_read <= 0) return 0; diff --git a/content.c b/content.c index c1ed4914217..d24cf72edca 100644 --- a/content.c +++ b/content.c @@ -230,7 +230,7 @@ static int content_7zip_file_read( { const void *ptr = (const void*)(output + offset); - if (!retro_write_file(optional_outfile, ptr, outsize)) + if (!filestream_write_file(optional_outfile, ptr, outsize)) { RARCH_ERR("Could not open outfilepath %s.\n", optional_outfile); @@ -489,7 +489,8 @@ static int content_zip_file_decompressed( { RARCH_LOG("Extracting file : %s\n", st->opt_file); memcpy(buf, handle.data, size); - if (!retro_write_file(st->opt_file, buf, size)) + + if (!filestream_write_file(st->opt_file, buf, size)) goto_error = true; } @@ -642,7 +643,7 @@ static int content_file_compressed_read( * @length : Number of items read, -1 on error. * * Read the contents of a file into @buf. Will call content_file_compressed_read - * if path contains a compressed file, otherwise will call retro_read_file(). + * if path contains a compressed file, otherwise will call filestream_read_file(). * * Returns: 1 if file read, 0 on error. */ @@ -655,7 +656,7 @@ static int content_file_read(const char *path, void **buf, ssize_t *length) return 1; } #endif - return retro_read_file(path, buf, length); + return filestream_read_file(path, buf, length); } struct string_list *compressed_file_list_new(const char *path, @@ -985,7 +986,7 @@ static bool dump_to_file_desperate(const void *data, strftime(timebuf, sizeof(timebuf), "%Y-%m-%d-%H-%M-%S", localtime(&time_)); strlcat(path, timebuf, sizeof(path)); - if (!retro_write_file(path, data, size)) + if (!filestream_write_file(path, data, size)) return false; RARCH_WARN("Succeeded in saving RAM data to \"%s\".\n", path); @@ -1032,7 +1033,7 @@ static bool content_save_state(const char *path) ret = core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); if (ret) - ret = retro_write_file(path, data, info.size); + ret = filestream_write_file(path, data, info.size); else { RARCH_ERR("%s \"%s\".\n", @@ -1063,7 +1064,7 @@ static bool content_load_state(const char *path) struct sram_block *blocks = NULL; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - bool ret = retro_read_file(path, &buf, &size); + bool ret = filestream_read_file(path, &buf, &size); RARCH_LOG("%s: \"%s\".\n", msg_hash_to_str(MSG_LOADING_STATE), @@ -1189,7 +1190,7 @@ static bool load_ram_file(void *data) if (mem_info.size == 0 || !mem_info.data) return false; - if (!retro_read_file(ram->path, &buf, &rc)) + if (!filestream_read_file(ram->path, &buf, &rc)) return false; if (rc > 0) @@ -1232,7 +1233,7 @@ static bool save_ram_file(ram_type_t *ram) if (!mem_info.data || mem_info.size == 0) return false; - if (!retro_write_file(ram->path, mem_info.data, mem_info.size)) + if (!filestream_write_file(ram->path, mem_info.data, mem_info.size)) { RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM)); diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 902f0714ddd..431438dcaf0 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -274,7 +274,7 @@ static void cpulist_read_from(CpuList* list, const char* filename) list->mask = 0; - if (retro_read_file(filename, (void**)&buf, &length) != 1) + if (filestream_read_file(filename, (void**)&buf, &length) != 1) { RARCH_ERR("Could not read %s: %s\n", filename, strerror(errno)); return; @@ -317,7 +317,7 @@ static void linux_cpu_init(void) g_cpuFeatures = 0; g_cpuCount = 1; - if (retro_read_file("/proc/cpuinfo", &buf, &length) != 1) + if (filestream_read_file("/proc/cpuinfo", &buf, &length) != 1) return; /* Count the CPU cores, the value may be 0 for single-core CPUs */ @@ -1008,11 +1008,11 @@ static void check_proc_acpi_battery(const char * node, bool * have_battery, snprintf(path, sizeof(path), "%s/%s/%s", base, node, "state"); - if (!retro_read_file(path, (void**)&buf, &length)) + if (!filestream_read_file(path, (void**)&buf, &length)) goto end; snprintf(path, sizeof(path), "%s/%s/%s", base, node, "info"); - if (!retro_read_file(path, (void**)&buf_info, &length)) + if (!filestream_read_file(path, (void**)&buf_info, &length)) goto end; ptr = &buf[0]; @@ -1133,7 +1133,7 @@ static void check_proc_acpi_sysfs_battery(const char *node, return; snprintf(path, sizeof(path), "%s/%s/%s", base, node, "status"); - if (retro_read_file(path, (void**)&buf, &length) != 1) + if (filestream_read_file(path, (void**)&buf, &length) != 1) return; if (strstr((char*)buf, "Discharging")) @@ -1142,7 +1142,7 @@ static void check_proc_acpi_sysfs_battery(const char *node, *have_battery = true; snprintf(path, sizeof(path), "%s/%s/%s", base, node, "capacity"); - if (retro_read_file(path, (void**)&buf, &length) != 1) + if (filestream_read_file(path, (void**)&buf, &length) != 1) goto end; capacity = atoi(buf); @@ -1166,7 +1166,7 @@ static void check_proc_acpi_ac_adapter(const char * node, bool *have_ac) ssize_t length = 0; snprintf(path, sizeof(path), "%s/%s/%s", base, node, "state"); - if (retro_read_file(path, (void**)&buf, &length) != 1) + if (filestream_read_file(path, (void**)&buf, &length) != 1) return; ptr = &buf[0]; @@ -1193,7 +1193,7 @@ static void check_proc_acpi_sysfs_ac_adapter(const char * node, bool *have_ac) const char *base = proc_acpi_sysfs_ac_adapter_path; snprintf(path, sizeof(path), "%s/%s", base, "online"); - if (retro_read_file(path, (void**)&buf, &length) != 1) + if (filestream_read_file(path, (void**)&buf, &length) != 1) return; if (strstr((char*)buf, "1")) @@ -1248,7 +1248,7 @@ static bool frontend_linux_powerstate_check_apm( char *buf = NULL; char *str = NULL; - if (retro_read_file(proc_apm_path, (void**)&buf, &length) != 1) + if (filestream_read_file(proc_apm_path, (void**)&buf, &length) != 1) goto error; ptr = &buf[0]; diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 6c361d49d93..340ef8308b7 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -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 = retro_fopen("/screenshot.tga", RFILE_MODE_WRITE, -1); + RFILE *out = filestream_fopen("/screenshot.tga", RFILE_MODE_WRITE, -1); if (!out) return; - retro_fwrite(out, tga_header, sizeof(tga_header)); + filestream_fwrite(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; } - retro_fwrite(out, line, sizeof(line)); + filestream_fwrite(out, line, sizeof(line)); } - retro_fclose(out); + filestream_fclose(out); } #endif diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 1555b4ac906..3677f9ed41f 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -324,7 +324,7 @@ static void free_drm_resources(gfx_ctx_drm_data_t *drm) drm_free(); if (g_drm_fd >= 0) - retro_fclose(drm->drm); + filestream_fclose(drm->drm); g_gbm_surface = NULL; g_gbm_dev = NULL; @@ -395,14 +395,14 @@ static void *gfx_ctx_drm_init(void *video_driver) } gpu = gpu_descriptors->elems[gpu_index++].data; - drm->drm = retro_fopen(gpu, RFILE_MODE_READ_WRITE, -1); + drm->drm = filestream_fopen(gpu, RFILE_MODE_READ_WRITE, -1); if (!drm->drm) { RARCH_WARN("[KMS]: Couldn't open DRM device.\n"); goto nextgpu; } - fd = retro_get_fd(drm->drm); + fd = filestream_get_fd(drm->drm); if (!drm_get_resources(fd)) goto nextgpu; diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 725efda5119..2b755584ec9 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -65,12 +65,12 @@ static void gfx_ctx_mali_fbdev_destroy(void *data) } /* Clear framebuffer and set cursor on again */ - fd = retro_fopen("/dev/tty", RFILE_MODE_READ_WRITE, -1); - fb = retro_get_fd(fd); + fd = filestream_fopen("/dev/tty", RFILE_MODE_READ_WRITE, -1); + fb = filestream_get_fd(fd); ioctl(fb, VT_ACTIVATE,5); ioctl(fb, VT_ACTIVATE,1); - retro_fclose(fd); + filestream_fclose(fd); system("setterm -cursor on"); } @@ -181,15 +181,16 @@ 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 = retro_fopen("/dev/fb0", RFILE_MODE_READ_WRITE, -1); - int fb = retro_get_fd(fd); + RFILE *fd = filestream_fopen("/dev/fb0", RFILE_MODE_READ_WRITE, -1); + int fb = filestream_get_fd(fd); if (ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) < 0) { RARCH_ERR("Error obtaining framebuffer info.\n"); goto error; } - retro_fclose(fd); + + filestream_fclose(fd); width = vinfo.xres; height = vinfo.yres; @@ -215,7 +216,7 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, error: if (fd) - retro_fclose(fd); + filestream_fclose(fd); RARCH_ERR("[Mali fbdev]: EGL error: %d.\n", eglGetError()); gfx_ctx_mali_fbdev_destroy(data); return false; diff --git a/gfx/drivers_font_renderer/stb.c b/gfx/drivers_font_renderer/stb.c index c24573cbb5b..c9593dcbe70 100644 --- a/gfx/drivers_font_renderer/stb.c +++ b/gfx/drivers_font_renderer/stb.c @@ -146,7 +146,7 @@ static void *font_renderer_stb_init(const char *font_path, float font_size) if (!self) goto error; - if (!retro_read_file(font_path, (void**)&font_data, NULL)) + if (!filestream_read_file(font_path, (void**)&font_data, NULL)) goto error; if (!font_renderer_stb_create_atlas(self, font_data, font_size, 512, 512)) diff --git a/gfx/drivers_shader/glslang_util.cpp b/gfx/drivers_shader/glslang_util.cpp index 3e83336578f..191d075fd95 100644 --- a/gfx/drivers_shader/glslang_util.cpp +++ b/gfx/drivers_shader/glslang_util.cpp @@ -35,7 +35,7 @@ static bool read_shader_file(const char *path, vector *output) struct string_list *list = NULL; char include_path[PATH_MAX]; - if (retro_read_file(path, (void**)&buf, &len) < 0) + if (filestream_read_file(path, (void**)&buf, &len) < 0) { RARCH_ERR("Failed to open shader file: \"%s\".\n", path); return false; diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 68416dc220a..3d156c79181 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -464,7 +464,7 @@ static bool gl_glsl_load_source_path(struct video_shader_pass *pass, const char *path) { ssize_t len; - bool ret = retro_read_file(path, + bool ret = filestream_read_file(path, (void**)&pass->source.string.vertex, &len); if (!ret || len <= 0) return false; diff --git a/gfx/video_state_python.c b/gfx/video_state_python.c index 069cf76ca9f..c875a6d9758 100644 --- a/gfx/video_state_python.c +++ b/gfx/video_state_python.c @@ -302,7 +302,7 @@ py_state_t *py_state_new(const char *script, * compiled with MSVC. */ ssize_t len; char *script_ = NULL; - bool ret = retro_read_file + bool ret = filestream_read_file (script, (void**)&script_, &len); if (!ret || len < 0) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 903cdd1ba1c..2812dd0b6ba 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -194,7 +194,7 @@ static bool video_texture_image_load_tga( ssize_t len; void *raw_buf = NULL; uint8_t *buf = NULL; - bool ret = retro_read_file(path, &raw_buf, &len); + bool ret = filestream_read_file(path, &raw_buf, &len); if (!ret || len < 0) { diff --git a/libretro-common/file/archive_file.c b/libretro-common/file/archive_file.c index e31d9ef2d08..9592f22947c 100644 --- a/libretro-common/file/archive_file.c +++ b/libretro-common/file/archive_file.c @@ -181,7 +181,7 @@ static void *file_archive_open(const char *path) if (!data) return NULL; - read_from_file = retro_read_file(path, &data->data, &ret); + read_from_file = filestream_read_file(path, &data->data, &ret); /* Failed to open archive? */ if (!read_from_file || ret < 0) @@ -447,7 +447,7 @@ static int file_archive_decompress_data_to_file( } #endif - if (!retro_write_file(path, handle->data, size)) + if (!filestream_write_file(path, handle->data, size)) { ret = false; goto end; @@ -655,7 +655,7 @@ bool file_archive_perform_mode(const char *path, const char *valid_exts, switch (cmode) { case ZLIB_MODE_UNCOMPRESSED: - if (!retro_write_file(path, cdata, size)) + if (!filestream_write_file(path, cdata, size)) return false; break; diff --git a/libretro-common/formats/bmp/rbmp_encode.c b/libretro-common/formats/bmp/rbmp_encode.c index 18038df1673..6c27d53073d 100644 --- a/libretro-common/formats/bmp/rbmp_encode.c +++ b/libretro-common/formats/bmp/rbmp_encode.c @@ -105,7 +105,7 @@ static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool header[52] = 0; header[53] = 0; - return retro_fwrite(file, header, sizeof(header)) == sizeof(header); + return filestream_fwrite(file, header, sizeof(header)) == sizeof(header); } static void dump_line_565_to_24(uint8_t *line, const uint16_t *src, unsigned width) @@ -161,8 +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) { - retro_fwrite(file, u.u8, pitch); - if(pad != 0) retro_fwrite(file, &zeros, pad); + filestream_fwrite(file, u.u8, pitch); + if(pad != 0) + filestream_fwrite(file, &zeros, pad); } return; } @@ -170,9 +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) - { - retro_fwrite(file, u.u8, line_size); - } + filestream_fwrite(file, u.u8, line_size); return; } @@ -186,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); - retro_fwrite(file, line, line_size); + filestream_fwrite(file, line, line_size); } } else /* type == RBMP_SOURCE_TYPE_RGB565 */ @@ -194,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); - retro_fwrite(file, line, line_size); + filestream_fwrite(file, line, line_size); } } @@ -205,7 +204,7 @@ bool rbmp_save_image(const char *filename, const void *frame, unsigned pitch, enum rbmp_source_type type) { bool ret; - RFILE *file = retro_fopen(filename, RFILE_MODE_WRITE, -1); + RFILE *file = filestream_fopen(filename, RFILE_MODE_WRITE, -1); if (!file) return false; @@ -214,7 +213,7 @@ bool rbmp_save_image(const char *filename, const void *frame, if (ret) dump_content(file, frame, width, height, pitch, type); - retro_fclose(file); + filestream_fclose(file); return ret; } diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index ea3c42573ed..a05645f89f6 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -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 retro_fwrite(file, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw); + return filestream_fwrite(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 (retro_fwrite(file, ihdr_raw, sizeof(ihdr_raw)) != sizeof(ihdr_raw)) + if (filestream_fwrite(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 (retro_fwrite(file, data, size) != (ssize_t)size) + if (filestream_fwrite(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 (retro_fwrite(file, data, sizeof(data)) != sizeof(data)) + if (filestream_fwrite(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 = retro_fopen(path, RFILE_MODE_WRITE, -1); + RFILE *file = filestream_fopen(path, RFILE_MODE_WRITE, -1); if (!file) GOTO_END_ERROR(); stream_backend = file_archive_get_default_file_backend(); - if (retro_fwrite(file, png_magic, sizeof(png_magic)) != sizeof(png_magic)) + if (filestream_fwrite(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: - retro_fclose(file); + filestream_fclose(file); free(encode_buf); free(deflate_buf); free(rgba_line); diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index d92a6cfd255..11df02e343e 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -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 = retro_fopen(path, RFILE_MODE_READ, -1); + RFILE *file = filestream_fopen(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; - retro_fseek(file, 0, SEEK_END); - len = retro_ftell(file); - retro_frewind(file); + filestream_fseek(file, 0, SEEK_END); + len = filestream_ftell(file); + filestream_frewind(file); memory_buffer = (char*)malloc(len + 1); if (!memory_buffer) goto error; memory_buffer[len] = '\0'; - if (retro_fread(file, memory_buffer, len) != (size_t)len) + if (filestream_fread(file, memory_buffer, len) != (size_t)len) goto error; - retro_fclose(file); + filestream_fclose(file); file = NULL; mem_ptr = memory_buffer; @@ -462,7 +462,7 @@ rxml_document_t *rxml_load_document(const char *path) error: free(memory_buffer); - retro_fclose(file); + filestream_fclose(file); rxml_free_document(doc); return NULL; } diff --git a/libretro-common/hash/rhash.c b/libretro-common/hash/rhash.c index 6e11e6ebbc0..98a2ab2ecd7 100644 --- a/libretro-common/hash/rhash.c +++ b/libretro-common/hash/rhash.c @@ -511,7 +511,7 @@ int sha1_calculate(const char *path, char *result) unsigned char buff[4096] = {0}; SHA1Context sha; int rv = 1; - RFILE *fd = retro_fopen(path, RFILE_MODE_READ, -1); + RFILE *fd = filestream_fopen(path, RFILE_MODE_READ, -1); if (!fd) goto error; @@ -520,7 +520,7 @@ int sha1_calculate(const char *path, char *result) do { - rv = retro_fread(fd, buff, 4096); + rv = filestream_fread(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]); - retro_fclose(fd); + filestream_fclose(fd); return 0; error: if (fd) - retro_fclose(fd); + filestream_fclose(fd); return -1; } diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index de7a90fd7fd..546fe7acf8a 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -48,25 +48,25 @@ enum RFILE_HINT_MMAP = 1<<9 /* requires RFILE_MODE_READ */ }; -RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len); +RFILE *filestream_fopen(const char *path, unsigned mode, ssize_t len); -ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence); +ssize_t filestream_fseek(RFILE *stream, ssize_t offset, int whence); -ssize_t retro_fread(RFILE *stream, void *s, size_t len); +ssize_t filestream_fread(RFILE *stream, void *s, size_t len); -ssize_t retro_fwrite(RFILE *stream, const void *s, size_t len); +ssize_t filestream_fwrite(RFILE *stream, const void *s, size_t len); -ssize_t retro_ftell(RFILE *stream); +ssize_t filestream_ftell(RFILE *stream); -void retro_frewind(RFILE *stream); +void filestream_frewind(RFILE *stream); -int retro_fclose(RFILE *stream); +int filestream_fclose(RFILE *stream); -int retro_read_file(const char *path, void **buf, ssize_t *len); +int filestream_read_file(const char *path, void **buf, ssize_t *len); -bool retro_write_file(const char *path, const void *data, ssize_t size); +bool filestream_write_file(const char *path, const void *data, ssize_t size); -int retro_get_fd(RFILE *stream); +int filestream_get_fd(RFILE *stream); #ifdef __cplusplus } diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 41a6810f23b..003cde9b4df 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -90,7 +90,7 @@ struct RFILE #endif }; -int retro_get_fd(RFILE *stream) +int filestream_get_fd(RFILE *stream) { if (!stream) return -1; @@ -105,7 +105,7 @@ int retro_get_fd(RFILE *stream) #endif } -RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len) +RFILE *filestream_fopen(const char *path, unsigned mode, ssize_t len) { int flags = 0; int mode_int = 0; @@ -213,12 +213,12 @@ RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len) { stream->mappos = 0; stream->mapped = NULL; - stream->mapsize = retro_fseek(stream, 0, SEEK_END); + stream->mapsize = filestream_fseek(stream, 0, SEEK_END); if (stream->mapsize == (uint64_t)-1) goto error; - retro_frewind(stream); + filestream_frewind(stream); stream->mapped = (uint8_t*)mmap((void*)0, stream->mapsize, PROT_READ, MAP_SHARED, stream->fd, 0); @@ -237,11 +237,11 @@ RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len) return stream; error: - retro_fclose(stream); + filestream_fclose(stream); return NULL; } -ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence) +ssize_t filestream_fseek(RFILE *stream, ssize_t offset, int whence) { int ret = 0; if (!stream) @@ -266,7 +266,8 @@ ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence) else #endif #ifdef HAVE_MMAP - /* Need to check stream->mapped because this function is called in retro_fopen() */ + /* Need to check stream->mapped because this function is + * called in filestream_fopen() */ if (stream->mapped && stream->hints & RFILE_HINT_MMAP) { /* fseek() returns error on under/overflow but allows cursor > EOF for @@ -308,7 +309,7 @@ ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence) #endif } -ssize_t retro_ftell(RFILE *stream) +ssize_t filestream_ftell(RFILE *stream) { if (!stream) return -1; @@ -326,7 +327,8 @@ ssize_t retro_ftell(RFILE *stream) else #endif #ifdef HAVE_MMAP - /* Need to check stream->mapped because this function is called in retro_fopen() */ + /* Need to check stream->mapped because this function + * is called in filestream_fopen() */ if (stream->mapped && stream->hints & RFILE_HINT_MMAP) return stream->mappos; else @@ -335,12 +337,12 @@ ssize_t retro_ftell(RFILE *stream) #endif } -void retro_frewind(RFILE *stream) +void filestream_frewind(RFILE *stream) { - retro_fseek(stream, 0L, SEEK_SET); + filestream_fseek(stream, 0L, SEEK_SET); } -ssize_t retro_fread(RFILE *stream, void *s, size_t len) +ssize_t filestream_fread(RFILE *stream, void *s, size_t len) { if (!stream || !s) return -1; @@ -377,7 +379,7 @@ ssize_t retro_fread(RFILE *stream, void *s, size_t len) #endif } -ssize_t retro_fwrite(RFILE *stream, const void *s, size_t len) +ssize_t filestream_fwrite(RFILE *stream, const void *s, size_t len) { if (!stream) return -1; @@ -403,7 +405,7 @@ ssize_t retro_fwrite(RFILE *stream, const void *s, size_t len) #endif } -int retro_fclose(RFILE *stream) +int filestream_fclose(RFILE *stream) { if (!stream) return -1; @@ -437,7 +439,7 @@ int retro_fclose(RFILE *stream) } /** - * retro_read_file: + * filestream_read_file: * @path : path to file. * @buf : buffer to allocate and read the contents of the * file into. Needs to be freed manually. @@ -446,12 +448,12 @@ int retro_fclose(RFILE *stream) * * Returns: number of items read, -1 on error. */ -int retro_read_file(const char *path, void **buf, ssize_t *len) +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 = retro_fopen(path, RFILE_MODE_READ, -1); + RFILE *file = filestream_fopen(path, RFILE_MODE_READ, -1); if (!file) { @@ -463,21 +465,21 @@ int retro_read_file(const char *path, void **buf, ssize_t *len) goto error; } - if (retro_fseek(file, 0, SEEK_END) != 0) + if (filestream_fseek(file, 0, SEEK_END) != 0) goto error; - content_buf_size = retro_ftell(file); + content_buf_size = filestream_ftell(file); if (content_buf_size < 0) goto error; - retro_frewind(file); + filestream_frewind(file); content_buf = malloc(content_buf_size + 1); if (!content_buf) goto error; - ret = retro_fread(file, content_buf, content_buf_size); + ret = filestream_fread(file, content_buf, content_buf_size); if (ret < 0) { #if __STDC_VERSION__ >= 199901L @@ -488,7 +490,7 @@ int retro_read_file(const char *path, void **buf, ssize_t *len) goto error; } - retro_fclose(file); + filestream_fclose(file); *buf = content_buf; @@ -503,7 +505,7 @@ int retro_read_file(const char *path, void **buf, ssize_t *len) error: if (file) - retro_fclose(file); + filestream_fclose(file); if (content_buf) free(content_buf); if (len) @@ -513,7 +515,7 @@ int retro_read_file(const char *path, void **buf, ssize_t *len) } /** - * retro_write_file: + * filestream_write_file: * @path : path to file. * @data : contents to write to the file. * @size : size of the contents. @@ -522,15 +524,15 @@ int retro_read_file(const char *path, void **buf, ssize_t *len) * * Returns: true (1) on success, false (0) otherwise. */ -bool retro_write_file(const char *path, const void *data, ssize_t size) +bool filestream_write_file(const char *path, const void *data, ssize_t size) { ssize_t ret = 0; - RFILE *file = retro_fopen(path, RFILE_MODE_WRITE, -1); + RFILE *file = filestream_fopen(path, RFILE_MODE_WRITE, -1); if (!file) return false; - ret = retro_fwrite(file, data, size); - retro_fclose(file); + ret = filestream_fwrite(file, data, size); + filestream_fclose(file); return (ret == size); } diff --git a/libretro-db/c_converter.c b/libretro-db/c_converter.c index 37405495bf8..3fa19d8285b 100644 --- a/libretro-db/c_converter.c +++ b/libretro-db/c_converter.c @@ -794,7 +794,7 @@ int main(int argc, char** argv) dat_buffer++; } - rdb_file = retro_fopen(rdb_path, RFILE_MODE_WRITE, -1); + rdb_file = filestream_fopen(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(); - retro_fclose(rdb_file); + filestream_fclose(rdb_file); dat_converter_list_free(dat_parser_list); diff --git a/libretro-db/libretrodb.c b/libretro-db/libretrodb.c index 0d6f1511f83..ed224d78130 100644 --- a/libretro-db/libretrodb.c +++ b/libretro-db/libretrodb.c @@ -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 = retro_fseek(fd, 0, SEEK_CUR); + ssize_t root = filestream_fseek(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 */ - retro_fseek(fd, sizeof(libretrodb_header_t), SEEK_CUR); + filestream_fseek(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(retro_fseek(fd, 0, SEEK_CUR)); + header.metadata_offset = swap_if_little64(filestream_fseek(fd, 0, SEEK_CUR)); md.count = item_count; libretrodb_write_metadata(fd, &md); - retro_fseek(fd, root, SEEK_SET); - retro_fwrite(fd, &header, sizeof(header)); + filestream_fseek(fd, root, SEEK_SET); + filestream_fwrite(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) - retro_fclose(db->fd); + filestream_fclose(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 = retro_fopen(path, RFILE_MODE_READ, -1); + RFILE *fd = filestream_fopen(path, RFILE_MODE_READ, -1); if (!fd) return -errno; strlcpy(db->path, path, sizeof(db->path)); - db->root = retro_fseek(fd, 0, SEEK_CUR); + db->root = filestream_fseek(fd, 0, SEEK_CUR); - if ((rv = retro_fread(fd, &header, sizeof(header))) == -1) + if ((rv = filestream_fread(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); - retro_fseek(fd, (ssize_t)header.metadata_offset, SEEK_SET); + filestream_fseek(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 = retro_fseek(fd, 0, SEEK_CUR); + db->first_index_offset = filestream_fseek(fd, 0, SEEK_CUR); db->fd = fd; return 0; error: if (fd) - retro_fclose(fd); + filestream_fclose(fd); return rv; } static int libretrodb_find_index(libretrodb_t *db, const char *index_name, libretrodb_index_t *idx) { - ssize_t eof = retro_fseek(db->fd, 0, SEEK_END); - ssize_t offset = retro_fseek(db->fd, + ssize_t eof = filestream_fseek(db->fd, 0, SEEK_END); + ssize_t offset = filestream_fseek(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 = retro_fseek(db->fd, (ssize_t)idx->next, SEEK_CUR); + offset = filestream_fseek(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 = retro_fread(db->fd, buff_, bufflen - nread); + rv = filestream_fread(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) - retro_fseek(db->fd, (ssize_t)offset, SEEK_SET); + filestream_fseek(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 retro_fseek(cursor->fd, + return filestream_fseek(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) - retro_fclose(cursor->fd); + filestream_fclose(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 = retro_fopen(db->path, RFILE_MODE_READ | RFILE_HINT_MMAP, -1); + cursor->fd = filestream_fopen(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 (retro_fwrite(nictx->db->fd, value, + if (filestream_fwrite(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 retro_fseek(db->fd, 0, SEEK_CUR); + return filestream_fseek(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 = retro_fseek(db->fd, 0, SEEK_END); + idx_header_offset = filestream_fseek(db->fd, 0, SEEK_END); (void)idx_header_offset; (void)rv; diff --git a/libretro-db/lua/lua_converter.c b/libretro-db/lua/lua_converter.c index e2ad50d8d4a..b920c8cdb33 100644 --- a/libretro-db/lua/lua_converter.c +++ b/libretro-db/lua/lua_converter.c @@ -9,6 +9,8 @@ #include #include +#include + #include "libretrodb.h" #include "lua_common.h" @@ -90,7 +92,7 @@ int main(int argc, char ** argv) call_init(L, argc - 2, (const char **) argv + 2); - dst = retro_fopen(db_file, RFILE_MODE_WRITE, -1); + dst = filestream_fopen(db_file, RFILE_MODE_WRITE, -1); if (!dst) { printf( @@ -106,6 +108,6 @@ int main(int argc, char ** argv) clean: lua_close(L); - retro_fclose(dst); + filestream_fclose(dst); return rv; } diff --git a/libretro-db/lua/testlib.c b/libretro-db/lua/testlib.c index 5ee953cb165..b61c5d5fb66 100644 --- a/libretro-db/lua/testlib.c +++ b/libretro-db/lua/testlib.c @@ -6,6 +6,8 @@ #include #include +#include + #include "lua.h" #include "lauxlib.h" @@ -104,7 +106,7 @@ static int create_db(lua_State *L) } lua_setfield(L, LUA_REGISTRYINDEX, "testlib_get_value"); - dst = retro_fopen(db_file, RFILE_MODE_WRITE, -1); + dst = filestream_fopen(db_file, RFILE_MODE_WRITE, -1); if (!dst) { lua_pushstring(L, "Could not open destination file"); @@ -112,7 +114,7 @@ static int create_db(lua_State *L) } libretrodb_create(dst, &value_provider, L); - retro_fclose(dst); + filestream_fclose(dst); return 0; } diff --git a/libretro-db/rmsgpack.c b/libretro-db/rmsgpack.c index f608f9b712f..5f548d094a8 100644 --- a/libretro-db/rmsgpack.c +++ b/libretro-db/rmsgpack.c @@ -106,26 +106,26 @@ int rmsgpack_write_array_header(RFILE *fd, uint32_t size) if (size < 16) { size = (size | MPF_FIXARRAY); - if (retro_fwrite(fd, &size, sizeof(int8_t)) == -1) + if (filestream_fwrite(fd, &size, sizeof(int8_t)) == -1) goto error; return sizeof(int8_t); } else if (size == (uint16_t)size) { - if (retro_fwrite(fd, &MPF_ARRAY16, sizeof(MPF_ARRAY16)) == -1) + if (filestream_fwrite(fd, &MPF_ARRAY16, sizeof(MPF_ARRAY16)) == -1) goto error; tmp_i16 = swap_if_little16(size); - if (retro_fwrite(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1) + if (filestream_fwrite(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1) goto error; return sizeof(int8_t) + sizeof(uint16_t); } - if (retro_fwrite(fd, &MPF_ARRAY32, sizeof(MPF_ARRAY32)) == -1) + if (filestream_fwrite(fd, &MPF_ARRAY32, sizeof(MPF_ARRAY32)) == -1) goto error; tmp_i32 = swap_if_little32(size); - if (retro_fwrite(fd, (void *)(&tmp_i32), sizeof(uint32_t)) == -1) + if (filestream_fwrite(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 (retro_fwrite(fd, &size, sizeof(int8_t)) == -1) + if (filestream_fwrite(fd, &size, sizeof(int8_t)) == -1) goto error; return sizeof(int8_t); } else if (size < (uint16_t)size) { - if (retro_fwrite(fd, &MPF_MAP16, sizeof(MPF_MAP16)) == -1) + if (filestream_fwrite(fd, &MPF_MAP16, sizeof(MPF_MAP16)) == -1) goto error; tmp_i16 = swap_if_little16(size); - if (retro_fwrite(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1) + if (filestream_fwrite(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1) goto error; return sizeof(uint8_t) + sizeof(uint16_t); } tmp_i32 = swap_if_little32(size); - if (retro_fwrite(fd, &MPF_MAP32, sizeof(MPF_MAP32)) == -1) + if (filestream_fwrite(fd, &MPF_MAP32, sizeof(MPF_MAP32)) == -1) goto error; - if (retro_fwrite(fd, (void *)(&tmp_i32), sizeof(uint32_t)) == -1) + if (filestream_fwrite(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 (retro_fwrite(fd, &fixlen, sizeof(int8_t)) == -1) + if (filestream_fwrite(fd, &fixlen, sizeof(int8_t)) == -1) goto error; } else if (len < (1 << 8)) { - if (retro_fwrite(fd, &MPF_STR8, sizeof(MPF_STR8)) == -1) + if (filestream_fwrite(fd, &MPF_STR8, sizeof(MPF_STR8)) == -1) goto error; - if (retro_fwrite(fd, &len, sizeof(uint8_t)) == -1) + if (filestream_fwrite(fd, &len, sizeof(uint8_t)) == -1) goto error; written += sizeof(uint8_t); } else if (len < (1 << 16)) { - if (retro_fwrite(fd, &MPF_STR16, sizeof(MPF_STR16)) == -1) + if (filestream_fwrite(fd, &MPF_STR16, sizeof(MPF_STR16)) == -1) goto error; tmp_i16 = swap_if_little16(len); - if (retro_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1) + if (filestream_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1) goto error; written += sizeof(uint16_t); } else { - if (retro_fwrite(fd, &MPF_STR32, sizeof(MPF_STR32)) == -1) + if (filestream_fwrite(fd, &MPF_STR32, sizeof(MPF_STR32)) == -1) goto error; tmp_i32 = swap_if_little32(len); - if (retro_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1) + if (filestream_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1) goto error; written += sizeof(uint32_t); } - if (retro_fwrite(fd, s, len) == -1) + if (filestream_fwrite(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 (retro_fwrite(fd, &MPF_BIN8, sizeof(MPF_BIN8)) == -1) + if (filestream_fwrite(fd, &MPF_BIN8, sizeof(MPF_BIN8)) == -1) goto error; - if (retro_fwrite(fd, &len, sizeof(uint8_t)) == -1) + if (filestream_fwrite(fd, &len, sizeof(uint8_t)) == -1) goto error; written += sizeof(uint8_t); } else if (len == (uint16_t)len) { - if (retro_fwrite(fd, &MPF_BIN16, sizeof(MPF_BIN16)) == -1) + if (filestream_fwrite(fd, &MPF_BIN16, sizeof(MPF_BIN16)) == -1) goto error; tmp_i16 = swap_if_little16(len); - if (retro_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1) + if (filestream_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1) goto error; written += sizeof(uint16_t); } else { - if (retro_fwrite(fd, &MPF_BIN32, sizeof(MPF_BIN32)) == -1) + if (filestream_fwrite(fd, &MPF_BIN32, sizeof(MPF_BIN32)) == -1) goto error; tmp_i32 = swap_if_little32(len); - if (retro_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1) + if (filestream_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1) goto error; written += sizeof(uint32_t); } - if (retro_fwrite(fd, s, len) == -1) + if (filestream_fwrite(fd, s, len) == -1) goto error; written += len; @@ -264,7 +264,7 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len) int rmsgpack_write_nil(RFILE *fd) { - if (retro_fwrite(fd, &MPF_NIL, sizeof(MPF_NIL)) == -1) + if (filestream_fwrite(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 (retro_fwrite(fd, &MPF_TRUE, sizeof(MPF_TRUE)) == -1) + if (filestream_fwrite(fd, &MPF_TRUE, sizeof(MPF_TRUE)) == -1) goto error; } - if (retro_fwrite(fd, &MPF_FALSE, sizeof(MPF_FALSE)) == -1) + if (filestream_fwrite(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 (retro_fwrite(fd, &value, sizeof(int8_t)) == -1) + if (filestream_fwrite(fd, &value, sizeof(int8_t)) == -1) goto error; } else if (value < 0 && value > -32) { tmpval = (value) | 0xe0; - if (retro_fwrite(fd, &tmpval, sizeof(uint8_t)) == -1) + if (filestream_fwrite(fd, &tmpval, sizeof(uint8_t)) == -1) goto error; } else if (value == (int8_t)value) { - if (retro_fwrite(fd, &MPF_INT8, sizeof(MPF_INT8)) == -1) + if (filestream_fwrite(fd, &MPF_INT8, sizeof(MPF_INT8)) == -1) goto error; - if (retro_fwrite(fd, &value, sizeof(int8_t)) == -1) + if (filestream_fwrite(fd, &value, sizeof(int8_t)) == -1) goto error; written += sizeof(int8_t); } else if (value == (int16_t)value) { - if (retro_fwrite(fd, &MPF_INT16, sizeof(MPF_INT16)) == -1) + if (filestream_fwrite(fd, &MPF_INT16, sizeof(MPF_INT16)) == -1) goto error; tmp_i16 = swap_if_little16((uint16_t)value); - if (retro_fwrite(fd, &tmp_i16, sizeof(int16_t)) == -1) + if (filestream_fwrite(fd, &tmp_i16, sizeof(int16_t)) == -1) goto error; written += sizeof(int16_t); } else if (value == (int32_t)value) { - if (retro_fwrite(fd, &MPF_INT32, sizeof(MPF_INT32)) == -1) + if (filestream_fwrite(fd, &MPF_INT32, sizeof(MPF_INT32)) == -1) goto error; tmp_i32 = swap_if_little32((uint32_t)value); - if (retro_fwrite(fd, &tmp_i32, sizeof(int32_t)) == -1) + if (filestream_fwrite(fd, &tmp_i32, sizeof(int32_t)) == -1) goto error; written += sizeof(int32_t); } else { - if (retro_fwrite(fd, &MPF_INT64, sizeof(MPF_INT64)) == -1) + if (filestream_fwrite(fd, &MPF_INT64, sizeof(MPF_INT64)) == -1) goto error; value = swap_if_little64(value); - if (retro_fwrite(fd, &value, sizeof(int64_t)) == -1) + if (filestream_fwrite(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 (retro_fwrite(fd, &MPF_UINT8, sizeof(MPF_UINT8)) == -1) + if (filestream_fwrite(fd, &MPF_UINT8, sizeof(MPF_UINT8)) == -1) goto error; - if (retro_fwrite(fd, &value, sizeof(uint8_t)) == -1) + if (filestream_fwrite(fd, &value, sizeof(uint8_t)) == -1) goto error; written += sizeof(uint8_t); } else if (value == (uint16_t)value) { - if (retro_fwrite(fd, &MPF_UINT16, sizeof(MPF_UINT16)) == -1) + if (filestream_fwrite(fd, &MPF_UINT16, sizeof(MPF_UINT16)) == -1) goto error; tmp_i16 = swap_if_little16((uint16_t)value); - if (retro_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1) + if (filestream_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1) goto error; written += sizeof(uint16_t); } else if (value == (uint32_t)value) { - if (retro_fwrite(fd, &MPF_UINT32, sizeof(MPF_UINT32)) == -1) + if (filestream_fwrite(fd, &MPF_UINT32, sizeof(MPF_UINT32)) == -1) goto error; tmp_i32 = swap_if_little32((uint32_t)value); - if (retro_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1) + if (filestream_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1) goto error; written += sizeof(uint32_t); } else { - if (retro_fwrite(fd, &MPF_UINT64, sizeof(MPF_UINT64)) == -1) + if (filestream_fwrite(fd, &MPF_UINT64, sizeof(MPF_UINT64)) == -1) goto error; value = swap_if_little64(value); - if (retro_fwrite(fd, &value, sizeof(uint64_t)) == -1) + if (filestream_fwrite(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 (retro_fread(fd, &tmp, size) == -1) + if (filestream_fread(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 (retro_fread(fd, &tmp64, size) == -1) + if (filestream_fread(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 = retro_fread(fd, *pbuff, (size_t)tmp_len)) == -1) + if ((read_len = filestream_fread(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 (retro_fread(fd, &type, sizeof(uint8_t)) == -1) + if (filestream_fread(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 = retro_fread(fd, buff, (ssize_t)tmp_len)) == -1) + if ((read_len = filestream_fread(fd, buff, (ssize_t)tmp_len)) == -1) { free(buff); goto error; diff --git a/libretro-db/rmsgpack_test.c b/libretro-db/rmsgpack_test.c index aad5bd97ed8..ee576880ca3 100644 --- a/libretro-db/rmsgpack_test.c +++ b/libretro-db/rmsgpack_test.c @@ -26,6 +26,8 @@ #include #include +#include + #include "rmsgpack.h" struct stub_state @@ -184,7 +186,7 @@ static struct rmsgpack_read_callbacks stub_callbacks = { int main(void) { struct stub_state state; - RFILE *fd = retro_fopen("test.msgpack", RFILE_MODE_READ, 0); + RFILE *fd = filestream_fopen("test.msgpack", RFILE_MODE_READ, 0); state.i = 0; state.stack[0] = 0; @@ -192,7 +194,7 @@ int main(void) rmsgpack_read(fd, &stub_callbacks, &state); printf("Test succeeded.\n"); - retro_fclose(fd); + filestream_fclose(fd); return 0; } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index aaf28e4537b..a2bd9dc512e 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1354,7 +1354,7 @@ static void cb_generic_download(void *task_data, fill_pathname_join(output_path, dir_path, transf->path, sizeof(output_path)); - if (!retro_write_file(output_path, data->data, data->len)) + if (!filestream_write_file(output_path, data->data, data->len)) { err = "Write failed."; goto finish; diff --git a/menu/drivers/zr_common.c b/menu/drivers/zr_common.c index 5be514a702a..a1905e2c866 100644 --- a/menu/drivers/zr_common.c +++ b/menu/drivers/zr_common.c @@ -47,7 +47,7 @@ char* zr_common_file_load(const char* path, size_t* size) { void *buf; ssize_t *length = (ssize_t*)size; - retro_read_file(path, &buf, length); + filestream_read_file(path, &buf, length); return buf; } diff --git a/menu/menu_content.c b/menu/menu_content.c index bc0a3ef95e0..8ab50c154a0 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -181,14 +181,14 @@ static bool menu_content_load_from_playlist(void *data) free(path_tolower); - fp = retro_fopen(path_check, RFILE_MODE_READ, -1); + fp = filestream_fopen(path_check, RFILE_MODE_READ, -1); free(path_check); if (!fp) goto error; - retro_fclose(fp); + filestream_fclose(fp); } runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); diff --git a/patch.c b/patch.c index 35a598e435f..a5d7e441835 100644 --- a/patch.c +++ b/patch.c @@ -517,7 +517,7 @@ static bool apply_patch_content(uint8_t **buf, if (!path_is_valid(patch_path)) return false; - if (!retro_read_file(patch_path, &patch_data, &patch_size)) + if (!filestream_read_file(patch_path, &patch_data, &patch_size)) return false; if (patch_size < 0) return false; diff --git a/retroarch.c b/retroarch.c index 75f4ea08afd..f4db7cf63bf 100644 --- a/retroarch.c +++ b/retroarch.c @@ -25,7 +25,6 @@ #include #include -#include #include #ifdef _WIN32 diff --git a/tasks/task_database.c b/tasks/task_database.c index cc65952c680..6392e68d7e2 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -208,7 +208,7 @@ static int database_info_iterate_playlist( default: { ssize_t ret; - int read_from = retro_read_file( + int read_from = filestream_read_file( name, (void**)&db_state->buf, &ret); #ifdef HAVE_ZLIB const struct file_archive_file_backend *stream_backend = diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index 638f7a33de0..47c0b920301 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -65,7 +65,7 @@ static ssize_t get_token(RFILE *fd, char *token, size_t max_len) while (1) { - int rv = retro_fread(fd, c, 1); + int rv = filestream_fread(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 = retro_fopen(track_path, RFILE_MODE_READ, -1); + RFILE *fp = filestream_fopen(track_path, RFILE_MODE_READ, -1); if (!fp) return 0; is_mode1 = 0; - retro_fseek(fp, 0, SEEK_END); + filestream_fseek(fp, 0, SEEK_END); if (!sub_channel_mixed) { - if (!(retro_ftell(fp) & 0x7FF)) + if (!(filestream_ftell(fp) & 0x7FF)) { unsigned int mode_test = 0; - retro_fseek(fp, 0, SEEK_SET); - retro_fread(fp, &mode_test, 4); + filestream_fseek(fp, 0, SEEK_SET); + filestream_fread(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; - retro_fseek(fp, 156 + skip + 16 * frame_size, SEEK_SET); - retro_fread(fp, buffer, 6); + filestream_fseek(fp, 156 + skip + 16 * frame_size, SEEK_SET); + filestream_fread(fp, buffer, 6); cd_sector = buffer[2] | (buffer[3] << 8) | (buffer[4] << 16); - retro_fseek(fp, skip + cd_sector * frame_size, SEEK_SET); - retro_fread(fp, buffer, 2048 * 2); + filestream_fseek(fp, skip + cd_sector * frame_size, SEEK_SET); + filestream_fread(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); - retro_fseek(fp, 13 + skip + cd_sector * frame_size, SEEK_SET); - retro_fread(fp, buffer, 256); + filestream_fseek(fp, 13 + skip + cd_sector * frame_size, SEEK_SET); + filestream_fread(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; - retro_fclose(fp); + filestream_fclose(fp); return 1; } @@ -225,9 +225,9 @@ int detect_ps1_game(const char *track_path, char *game_id) int detect_psp_game(const char *track_path, char *game_id) { - bool rv = false; unsigned pos; - RFILE *fd = retro_fopen(track_path, RFILE_MODE_READ, -1); + bool rv = false; + RFILE *fd = filestream_fopen(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++) { - retro_fseek(fd, pos, SEEK_SET); + filestream_fseek(fd, pos, SEEK_SET); - if (retro_fread(fd, game_id, 5) > 0) + if (filestream_fread(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-") ) { - retro_fseek(fd, pos, SEEK_SET); - if (retro_fread(fd, game_id, 10) > 0) + filestream_fseek(fd, pos, SEEK_SET); + if (filestream_fread(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; } - retro_fclose(fd); + filestream_fclose(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 = retro_fopen(track_path, RFILE_MODE_READ, -1); + RFILE *fd = filestream_fopen(track_path, RFILE_MODE_READ, -1); if (!fd) { @@ -307,8 +307,8 @@ int detect_system(const char *track_path, int32_t offset, goto clean; } - retro_fseek(fd, offset, SEEK_SET); - if (retro_fread(fd, magic, MAGIC_LEN) < MAGIC_LEN) + filestream_fseek(fd, offset, SEEK_SET); + if (filestream_fread(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, } } - retro_fseek(fd, 0x8008, SEEK_SET); - if (retro_fread(fd, magic, 8) > 0) + filestream_fseek(fd, 0x8008, SEEK_SET); + if (filestream_fread(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: - retro_fclose(fd); + filestream_fclose(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 = retro_fopen(cue_path, RFILE_MODE_READ, -1); + fd = filestream_fopen(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: - retro_fclose(fd); + filestream_fclose(fd); return rv; } diff --git a/tasks/task_http.c b/tasks/task_http.c index 260063a75f2..f7d9bbfc2d3 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "../msg_hash.h"