From 4cbf19c97ef3af2e55cdc477d9f616e12ea9d63b Mon Sep 17 00:00:00 2001 From: flyinghead Date: Tue, 7 Dec 2021 17:15:35 +0100 Subject: [PATCH] libretro: nvmem not saved when rom path mixes slash and backslash Issue https://github.com/libretro/flycast/issues/1114 --- shell/libretro/libretro.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/shell/libretro/libretro.cpp b/shell/libretro/libretro.cpp index 72343d15f..205fd7c09 100644 --- a/shell/libretro/libretro.cpp +++ b/shell/libretro/libretro.cpp @@ -962,14 +962,11 @@ static void extract_directory(char *buf, const char *path, size_t size) strncpy(buf, path, size - 1); buf[size - 1] = '\0'; - char *base = strrchr(buf, '/'); - if (!base) - base = strrchr(buf, '\\'); - + char *base = find_last_slash(buf); if (base) *base = '\0'; else - buf[0] = '\0'; + strncpy(buf, ".", size - 1); } static uint32_t map_gamepad_button(unsigned device, unsigned id) @@ -1364,11 +1361,10 @@ static void set_input_descriptors() static void extract_basename(char *buf, const char *path, size_t size) { - const char *base = strrchr(path, slash); + const char *base = find_last_slash(path); if (!base) base = path; - - if (*base == slash) + else base++; strncpy(buf, base, size - 1);