mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Merge pull request #1036 from timostrunk/fix_state_naming
Fix directory and naming of savestates, srm files.
This commit is contained in:
commit
c75f1d163b
@ -557,12 +557,14 @@ ifeq ($(WANT_MINIZ),1)
|
||||
deps/rzlib/ioapi.o \
|
||||
deps/rzlib/unzip.o
|
||||
else
|
||||
ifeq ($(HAVE_ZLIB),1)
|
||||
ZLIB_OBJS = deps/rzlib/unzip.o deps/rzlib/ioapi.o
|
||||
OBJ += $(ZLIB_OBJS)
|
||||
RETROLAUNCH_OBJ += $(ZLIB_OBJS)
|
||||
JOYCONFIG_OBJ += $(ZLIB_OBJS)
|
||||
HAVE_ZLIB_DEFLATE = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_ZLIB_DEFLATE),1)
|
||||
DEFINES += -DHAVE_ZLIB_DEFLATE
|
||||
|
36
file_path.c
36
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_bak,'#');
|
||||
if (ptr)
|
||||
ptr++;
|
||||
else
|
||||
ptr = ptr_bak;
|
||||
#endif
|
||||
|
||||
rarch_assert(strlcpy(out, ptr, size) < size);
|
||||
}
|
||||
|
||||
@ -450,7 +466,16 @@ void path_basedir(char *path)
|
||||
if (strlen(path) < 2)
|
||||
return;
|
||||
|
||||
char *last = find_last_slash(path);
|
||||
char *last;
|
||||
|
||||
#ifdef HAVE_COMPRESSION
|
||||
/* We want to find the directory with the zipfile in basedir. */
|
||||
last = strchr(path,'#');
|
||||
if (last)
|
||||
*last = '\0';
|
||||
#endif
|
||||
|
||||
last = find_last_slash(path);
|
||||
|
||||
if (last)
|
||||
last[1] = '\0';
|
||||
@ -470,6 +495,15 @@ const char *path_basename(const char *path)
|
||||
{
|
||||
const char *last = find_last_slash(path);
|
||||
|
||||
/* We cut either at the last hash or the last slash; whichever comes last */
|
||||
#ifdef HAVE_COMPRESSION
|
||||
const char *last_hash = strchr(path,'#');
|
||||
if (last_hash > last)
|
||||
{
|
||||
return last_hash + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (last)
|
||||
return last + 1;
|
||||
return path;
|
||||
|
23
retroarch.c
23
retroarch.c
@ -1023,6 +1023,29 @@ static void set_basename(const char *path)
|
||||
|
||||
strlcpy(g_extern.fullpath, path, sizeof(g_extern.fullpath));
|
||||
strlcpy(g_extern.basename, path, sizeof(g_extern.basename));
|
||||
/* Removing extension is a bit tricky for compressed files.
|
||||
* Basename means:
|
||||
* /file/to/path/game.extension should be:
|
||||
* /file/to/path/game
|
||||
*
|
||||
* Two things to consider here are: /file/to/path/ is expected
|
||||
* to be a directory and "game" is a single file. This is used for
|
||||
* states and srm default paths
|
||||
*
|
||||
* For compressed files we have:
|
||||
*
|
||||
* /file/to/path/comp.7z#game.extension and
|
||||
* /file/to/path/comp.7z#folder/game.extension
|
||||
*
|
||||
* The choice I take here is:
|
||||
* /file/to/path/game as basename. We might end up in a writable dir then
|
||||
* and the name of srm and states are meaningful.
|
||||
*
|
||||
*/
|
||||
#ifdef HAVE_COMPRESSION
|
||||
path_basedir(g_extern.basename);
|
||||
fill_pathname_dir(g_extern.basename,path,"",sizeof(g_extern.basename));
|
||||
#endif
|
||||
|
||||
if ((dst = strrchr(g_extern.basename, '.')))
|
||||
*dst = '\0';
|
||||
|
Loading…
x
Reference in New Issue
Block a user