Skip to content

Commit

Permalink
Rename 'filestream' functions
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Mar 24, 2016
1 parent 89d8963 commit e411274
Show file tree
Hide file tree
Showing 32 changed files with 243 additions and 236 deletions.
24 changes: 12 additions & 12 deletions cheevos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -1707,7 +1707,7 @@ static size_t cheevos_eval_md5(
size += num_read;
}

retro_fclose(file);
filestream_fclose(file);
return size;
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 10 additions & 9 deletions content.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.
*/
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down
18 changes: 9 additions & 9 deletions frontend/drivers/platform_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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"))
Expand All @@ -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);
Expand All @@ -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];
Expand All @@ -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"))
Expand Down Expand Up @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions gfx/drivers/gx_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions gfx/drivers_context/drm_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions gfx/drivers_context/mali_fbdev_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers_font_renderer/stb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers_shader/glslang_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static bool read_shader_file(const char *path, vector<string> *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;
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers_shader/shader_glsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gfx/video_state_python.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gfx/video_texture_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit e411274

Please sign in to comment.