diff --git a/Makefile.common b/Makefile.common index c005e803d1..52aad9b2cf 100644 --- a/Makefile.common +++ b/Makefile.common @@ -132,6 +132,7 @@ OBJ += frontend/frontend.o \ ui/drivers/null/ui_null_application.o \ core_impl.o \ retroarch.o \ + paths.o \ input/input_keyboard.o \ command.o \ msg_hash.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 1497bcee4f..939740d40c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -797,6 +797,7 @@ RETROARCH ============================================================ */ #include "../core_impl.c" #include "../retroarch.c" +#include "../paths.c" #include "../runloop.c" #include "../libretro-common/queues/task_queue.c" diff --git a/paths.c b/paths.c new file mode 100644 index 0000000000..17023cfb2d --- /dev/null +++ b/paths.c @@ -0,0 +1,61 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "paths.h" + +#include "runloop.h" + +void path_set_basename(const char *path) +{ + char *dst = NULL; + global_t *global = global_get_ptr(); + + runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)path); + strlcpy(global->name.base, path, sizeof(global->name.base)); + +#ifdef HAVE_COMPRESSION + /* 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 + * directory then and the name of srm and states are meaningful. + * + */ + path_basedir(global->name.base); + fill_pathname_dir(global->name.base, path, "", sizeof(global->name.base)); +#endif + + if ((dst = strrchr(global->name.base, '.'))) + *dst = '\0'; +} diff --git a/paths.h b/paths.h new file mode 100644 index 0000000000..414f03cb8d --- /dev/null +++ b/paths.h @@ -0,0 +1,28 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef __PATHS_H +#define __PATHS_H + +#include +#include + +RETRO_BEGIN_DECLS + +void path_set_basename(const char *path); + +RETRO_END_DECLS + +#endif diff --git a/retroarch.c b/retroarch.c index ca5559f93e..03a1668ab7 100644 --- a/retroarch.c +++ b/retroarch.c @@ -64,6 +64,7 @@ #include "driver.h" #include "msg_hash.h" #include "movie.h" +#include "paths.h" #include "file_path_special.h" #include "verbosity.h" @@ -338,42 +339,6 @@ static void retroarch_print_help(const char *arg0) "then exits.\n"); } -static void retroarch_set_basename(const char *path) -{ - char *dst = NULL; - global_t *global = global_get_ptr(); - - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)path); - strlcpy(global->name.base, path, sizeof(global->name.base)); - -#ifdef HAVE_COMPRESSION - /* 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 - * directory then and the name of srm and states are meaningful. - * - */ - path_basedir(global->name.base); - fill_pathname_dir(global->name.base, path, "", sizeof(global->name.base)); -#endif - - if ((dst = strrchr(global->name.base, '.'))) - *dst = '\0'; -} - static void retroarch_set_special_paths(char **argv, unsigned num_content) { unsigned i; @@ -381,7 +346,7 @@ static void retroarch_set_special_paths(char **argv, unsigned num_content) global_t *global = global_get_ptr(); /* First content file is the significant one. */ - retroarch_set_basename(argv[0]); + path_set_basename(argv[0]); global->subsystem_fullpaths = string_list_new(); retro_assert(global->subsystem_fullpaths); @@ -1603,7 +1568,7 @@ void retroarch_set_pathnames(const char *path) { global_t *global = global_get_ptr(); - retroarch_set_basename(path); + path_set_basename(path); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH)) fill_pathname_noext(global->name.savefile, global->name.base,