diff --git a/libretro.c b/libretro.c index 2f8fc34..24edca2 100644 --- a/libretro.c +++ b/libretro.c @@ -66,7 +66,7 @@ read_m3u(const char *file) { char line[PATH_MAX]; char name[PATH_MAX]; - FILE *f = fopen(file, "r"); + RFILE *f = filestream_open(file, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); g_DISK_TOTAL = 0; @@ -76,7 +76,7 @@ read_m3u(const char *file) return false; } - while (fgets(line, sizeof(line), f) && g_DISK_TOTAL <= M3U_MAX_FILE) + while (filestream_gets(f, line, sizeof(line)) && g_DISK_TOTAL <= M3U_MAX_FILE) { if (line[0] == '#') continue; @@ -98,6 +98,7 @@ read_m3u(const char *file) if (strlen(g_ROMS_DIR) + strlen(line) + 1 >= PATH_MAX) { retro_log_printf_cb(RETRO_LOG_ERROR, "Path too long\n"); + filestream_close(f); return false; } @@ -109,7 +110,7 @@ read_m3u(const char *file) } } - fclose(f); + filestream_close(f); return (g_DISK_TOTAL != 0); }