Fix issues with reading system3.ini and playlist made on Windows

- Replace backslashes in pathnames with slashes
- Strip '\r' in playlist
This commit is contained in:
kichikuou
2021-11-27 13:23:11 +09:00
parent dc471399e5
commit 80ea44e3c6
2 changed files with 19 additions and 7 deletions
+7 -4
View File
@@ -69,16 +69,19 @@ MAKO::~MAKO()
bool MAKO::load_playlist(const char* path)
{
FILE* fp = fopen(path, "rt");
FILE* fp = fopen(path, "r");
if (!fp) {
WARNING("Cannot open %s", path);
return false;
}
char buf[256];
while (fgets(buf, sizeof(buf) - 1, fp)) {
char *p = &buf[strlen(buf) - 1];
if (*p == '\n')
*p = '\0';
for (char *p = buf; *p; p++) {
if (*p == '\\')
*p = '/';
else if (*p == '\r' || *p == '\n')
*p = '\0';
}
playlist.push_back(buf[0] ? strdup(buf) : NULL);
}
fclose(fp);