diff --git a/src/config.cpp b/src/config.cpp index 77946f3..9287ea1 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -26,6 +26,15 @@ bool to_bool(const char *s, int lineno) return true; } +std::string normalize_path(std::string s) +{ + for (char& c : s) { + if (c == '\\') + c = '/'; + } + return s; +} + bool is_empty_line(const char *s) { for (; *s; s++) { @@ -132,11 +141,11 @@ void Config::load_ini() if (!strcasecmp(key, "noantialias")) no_antialias = to_bool(val, lineno); else if (!strcasecmp(key, "savedir")) - save_dir = val; + save_dir = normalize_path(val); else if (!strcasecmp(key, "fontfile")) - font_file = val; + font_file = normalize_path(val); else if (!strcasecmp(key, "playlist")) - playlist = val; + playlist = normalize_path(val); else if (!strcasecmp(key, "fm")) use_fm = to_bool(val, lineno); else if (!strcasecmp(key, "game")) diff --git a/src/linux/mako.cpp b/src/linux/mako.cpp index 06c2e96..3a8d4c8 100644 --- a/src/linux/mako.cpp +++ b/src/linux/mako.cpp @@ -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);