From 95f02d12f472e994c01fcdfe5085bc0a316e41a6 Mon Sep 17 00:00:00 2001 From: Timo Strunk Date: Wed, 17 Sep 2014 18:41:23 +0200 Subject: [PATCH] Basenames should now be correct also when using zipfiles. It is now always only the basename of the file in the zipfile. So if zipname == internalname, its zipname, like requested here: https://github.com/libretro/RetroArch/issues/1030#issuecomment-55810822 --- file_path.c | 16 ++++++++++++++++ retroarch.c | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/file_path.c b/file_path.c index 4ff3f5911a..0c305156fd 100644 --- a/file_path.c +++ b/file_path.c @@ -417,6 +417,22 @@ void fill_pathname_base(char *out, const char *in_path, size_t size) else ptr = in_path; + /* In case of compression, we also have to consider paths like + * /path/to/archive.7z#mygame.img + * and + * /path/to/archive.7z#folder/mygame.img + * basename would be mygame.img in both cases + */ + +#ifdef HAVE_COMPRESSION + const char *ptr_bak = ptr; + ptr = strchr(ptr,'#'); + if (ptr) + ptr++; + else + ptr = ptr_bak; +#endif + rarch_assert(strlcpy(out, ptr, size) < size); } diff --git a/retroarch.c b/retroarch.c index 1cb7268cb7..4b1ba0e323 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1022,7 +1022,7 @@ static void set_basename(const char *path) char *dst = NULL; strlcpy(g_extern.fullpath, path, sizeof(g_extern.fullpath)); - strlcpy(g_extern.basename, path, sizeof(g_extern.basename)); + fill_pathname_base(g_extern.basename, path, sizeof(g_extern.basename)); if ((dst = strrchr(g_extern.basename, '.'))) *dst = '\0';