mirror of
https://github.com/libretro/RetroArch
synced 2025-03-31 19:21:06 +00:00
Merge pull request #9059 from jdgleaver/playlist-fix
Fix playlist format detection
This commit is contained in:
commit
7afa9e3663
45
playlist.c
45
playlist.c
@ -1822,38 +1822,37 @@ static bool playlist_read_file(
|
|||||||
|
|
||||||
/* Detect format of playlist */
|
/* Detect format of playlist */
|
||||||
{
|
{
|
||||||
char buf[16] = {0};
|
char test_char = 0;
|
||||||
int64_t bytes_read = filestream_read(file, buf, 15);
|
|
||||||
|
|
||||||
/* Empty playlist file */
|
/* Read file until we find the first non-whitespace
|
||||||
if (bytes_read == 0)
|
* ASCII character */
|
||||||
|
while ((test_char <= 0x20) || (test_char >= 0x7F))
|
||||||
{
|
{
|
||||||
filestream_close(file);
|
test_char = filestream_getc(file);
|
||||||
return true;
|
|
||||||
|
/* Sanity check:
|
||||||
|
* - If filestream_getc() returns 0, stream is invalid
|
||||||
|
* - If filestream_getc() returns EOF, then no non-whitespace
|
||||||
|
* ASCII characters were found */
|
||||||
|
if ((test_char == 0) || (test_char == EOF))
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
filestream_seek(file, 0, SEEK_SET);
|
if (test_char == '{')
|
||||||
|
|
||||||
if (bytes_read == 15)
|
|
||||||
{
|
{
|
||||||
if (string_is_equal(buf, "{\n \"version\": "))
|
/* New playlist format detected */
|
||||||
{
|
/*RARCH_LOG("New playlist format detected.\n");*/
|
||||||
/* new playlist format detected */
|
new_format = true;
|
||||||
/*RARCH_LOG("New playlist format detected.\n");*/
|
|
||||||
new_format = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* old playlist format detected */
|
|
||||||
/*RARCH_LOG("Old playlist format detected.\n");*/
|
|
||||||
new_format = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* corrupt playlist? */
|
/* old playlist format detected */
|
||||||
RARCH_ERR("Could not detect playlist format.\n");
|
/*RARCH_LOG("Old playlist format detected.\n");*/
|
||||||
|
new_format = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset file to start */
|
||||||
|
filestream_seek(file, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_format)
|
if (new_format)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user