Commit 3c97af3b authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Make ReadM3U code use libretro-common file_stream

parent 71bc3bd5
Pipeline #19367 passed with stages
in 26 minutes and 41 seconds
......@@ -570,18 +570,19 @@ static uint8_t composite_palette[] = {
255, 255, 255
};
static bool ReadM3U(std::vector<std::string> &file_list, std::string path, unsigned depth = 0)
static void ReadM3U(std::vector<std::string> &file_list, std::string path, unsigned depth = 0)
{
std::string dir_path;
char linebuf[2048];
FILE *fp = fopen(path.c_str(), "rb");
RFILE *fp = filestream_open(path.c_str(), RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE);
if (!fp)
return false;
return;
MDFN_GetFilePathComponents(path, &dir_path);
while(fgets(linebuf, sizeof(linebuf), fp))
while(filestream_gets(fp, linebuf, sizeof(linebuf)) != NULL)
{
std::string efp;
......@@ -598,15 +599,13 @@ static bool ReadM3U(std::vector<std::string> &file_list, std::string path, unsig
if(efp == path)
{
log_cb(RETRO_LOG_ERROR, "M3U at \"%s\" references self.\n", efp.c_str());
fclose(fp);
return false;
goto end;
}
if(depth == 99)
{
log_cb(RETRO_LOG_ERROR, "M3U load recursion too deep!\n");
fclose(fp);
return false;
goto end;
}
ReadM3U(file_list, efp, depth++);
......@@ -615,9 +614,8 @@ static bool ReadM3U(std::vector<std::string> &file_list, std::string path, unsig
file_list.push_back(efp);
}
fclose(fp);
return true;
end:
filestream_close(fp);
}
static std::vector<CDIF *> CDInterfaces; // FIXME: Cleanup on error out.
......@@ -632,8 +630,7 @@ static bool MDFNI_LoadCD(const char *devicename)
{
std::vector<std::string> file_list;
if (ReadM3U(file_list, devicename))
ret = true;
ReadM3U(file_list, devicename);
for(unsigned i = 0; i < file_list.size(); i++)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment