Create file_path_str.c

This commit is contained in:
twinaphex 2016-06-20 05:20:14 +02:00
parent b3188195a8
commit 35b078857d
13 changed files with 54 additions and 29 deletions

View File

@ -150,6 +150,7 @@ OBJ += frontend/frontend.o \
libretro-common/file/nbio/nbio_stdio.o \
libretro-common/file/file_path.o \
file_path_special.o \
file_path_str.o \
libretro-common/hash/rhash.o \
audio/audio_driver.o \
input/input_driver.o \

View File

@ -33,6 +33,7 @@ PPU_SRCS = frontend/frontend_salamander.c \
libretro-common/compat/compat_strl.c \
libretro-common/streams/file_stream.c \
libretro-common/file/config_file.c \
file_path_str.c \
verbosity.c
ifeq ($(HAVE_LOGGER), 1)

View File

@ -941,7 +941,7 @@ static config_file_t *open_default_config_file(void)
#if defined(_WIN32) && !defined(_XBOX)
fill_pathname_application_path(app_path, sizeof(app_path));
fill_pathname_resolve_relative(conf_path, app_path,
"retroarch.cfg", sizeof(conf_path));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
conf = config_file_new(conf_path);
@ -951,7 +951,7 @@ static config_file_t *open_default_config_file(void)
sizeof(application_data)))
{
fill_pathname_join(conf_path, application_data,
"retroarch.cfg", sizeof(conf_path));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
conf = config_file_new(conf_path);
}
}
@ -969,7 +969,7 @@ static config_file_t *open_default_config_file(void)
/* Since this is a clean config file, we can
* safely use config_save_on_exit. */
fill_pathname_resolve_relative(conf_path, app_path,
"retroarch.cfg", sizeof(conf_path));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
config_set_bool(conf, "config_save_on_exit", true);
saved = config_file_write(conf, conf_path);
}
@ -993,7 +993,7 @@ static config_file_t *open_default_config_file(void)
path_mkdir(application_data);
fill_pathname_join(conf_path, application_data,
"retroarch.cfg", sizeof(conf_path));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
conf = config_file_new(conf_path);
if (!conf)
@ -1027,7 +1027,7 @@ static config_file_t *open_default_config_file(void)
if (has_application_data)
{
fill_pathname_join(conf_path, application_data,
"retroarch.cfg", sizeof(conf_path));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
conf = config_file_new(conf_path);
}
@ -1051,7 +1051,7 @@ static config_file_t *open_default_config_file(void)
fill_pathname_basedir(basedir, conf_path, sizeof(basedir));
fill_pathname_join(conf_path, conf_path, "retroarch.cfg", sizeof(conf_path));
fill_pathname_join(conf_path, conf_path, file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
if (path_mkdir(basedir))
{
@ -1059,7 +1059,7 @@ static config_file_t *open_default_config_file(void)
char skeleton_conf[PATH_MAX_LENGTH] = {0};
fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR,
"retroarch.cfg", sizeof(skeleton_conf));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(skeleton_conf));
conf = config_file_new(skeleton_conf);
if (conf)
RARCH_WARN("Config: using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf);

View File

@ -425,17 +425,3 @@ void fill_pathname_application_special(char *s, size_t len, enum application_spe
break;
}
}
const char *file_path_str(enum file_path_enum enum_idx)
{
switch (enum_idx)
{
case FILE_PATH_CONTENT_HISTORY:
return "content_history.lpl";
case FILE_PATH_UNKNOWN:
default:
break;
}
return "null";
}

View File

@ -25,7 +25,8 @@
enum file_path_enum
{
FILE_PATH_UNKNOWN = 0,
FILE_PATH_CONTENT_HISTORY
FILE_PATH_CONTENT_HISTORY,
FILE_PATH_MAIN_CONFIG
};
enum application_special_type

32
file_path_str.c Normal file
View File

@ -0,0 +1,32 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#include "file_path_special.h"
const char *file_path_str(enum file_path_enum enum_idx)
{
switch (enum_idx)
{
case FILE_PATH_CONTENT_HISTORY:
return "content_history.lpl";
case FILE_PATH_MAIN_CONFIG:
return "retroarch.cfg";
case FILE_PATH_UNKNOWN:
default:
break;
}
return "null";
}

View File

@ -81,7 +81,7 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[],
fill_pathname_join(g_defaults.dir.video_filter, g_defaults.dir.port,
"filters", sizeof(g_defaults.dir.remap));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
"retroarch.cfg", sizeof(g_defaults.path.config));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
}
static void frontend_ctr_deinit(void *data)

View File

@ -362,7 +362,8 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[],
fill_pathname_join(g_defaults.dir.assets, home_dir_buf, "assets", sizeof(g_defaults.dir.assets));
fill_pathname_join(g_defaults.dir.system, home_dir_buf, "system", sizeof(g_defaults.dir.system));
fill_pathname_join(g_defaults.dir.menu_config, home_dir_buf, "config", sizeof(g_defaults.dir.menu_config));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config,
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap));
fill_pathname_join(g_defaults.dir.database, home_dir_buf, "database/rdb", sizeof(g_defaults.dir.database));
fill_pathname_join(g_defaults.dir.cursor, home_dir_buf, "database/cursors", sizeof(g_defaults.dir.cursor));
@ -387,7 +388,8 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[],
fill_pathname_join(g_defaults.dir.playlist, application_data, "playlists", sizeof(g_defaults.dir.playlist));
fill_pathname_join(g_defaults.dir.thumbnails, application_data, "thumbnails", sizeof(g_defaults.dir.thumbnails));
fill_pathname_join(g_defaults.dir.menu_config, application_data, "config", sizeof(g_defaults.dir.menu_config));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config,
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap));
fill_pathname_join(g_defaults.dir.core_assets, application_data, "downloads", sizeof(g_defaults.dir.core_assets));
fill_pathname_join(g_defaults.dir.screenshot, application_data, "screenshots", sizeof(g_defaults.dir.screenshot));

View File

@ -33,6 +33,7 @@
#endif
#include "../frontend_driver.h"
#include "../../file_path_special.h"
#include "../../defines/ps3_defines.h"
#include "../../defaults.h"
#include "../../verbosity.h"
@ -221,7 +222,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
fill_pathname_join(g_defaults.dir.shader, g_defaults.dir.core,
"shaders_cg", sizeof(g_defaults.dir.shader));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
"retroarch.cfg", sizeof(g_defaults.path.config));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
fill_pathname_join(g_defaults.dir.overlay, g_defaults.dir.core,
"overlays", sizeof(g_defaults.dir.overlay));
fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.core,

View File

@ -107,7 +107,7 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[],
fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core,
"playlists", sizeof(g_defaults.dir.playlist));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
"retroarch.cfg", sizeof(g_defaults.path.config));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
fill_pathname_join(g_defaults.dir.cheats, g_defaults.dir.port,
"cheats", sizeof(g_defaults.dir.cheats));
fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.port,

View File

@ -50,7 +50,7 @@ static void frontend_qnx_get_environment_settings(int *argc, char *argv[],
void *data, void *params_data)
{
fill_pathname_join(g_defaults.path.config, "app/native",
"retroarch.cfg", sizeof(g_defaults.path.config));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
fill_pathname_join(g_defaults.dir.shader, "app/native",
"shaders_glsl", sizeof(g_defaults.dir.shader));
fill_pathname_join(g_defaults.dir.overlay, "app/native",

View File

@ -1127,7 +1127,7 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
strlcpy(g_defaults.dir.core, "D:", sizeof(g_defaults.dir.core));
strlcpy(g_defaults.dir.core_info, "D:", sizeof(g_defaults.dir.core_info));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.core,
"retroarch.cfg", sizeof(g_defaults.path.config));
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core,
"savestates", sizeof(g_defaults.dir.savestate));
fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core,

View File

@ -653,6 +653,7 @@ FILE
============================================================ */
#include "../libretro-common/file/file_path.c"
#include "../file_path_special.c"
#include "../file_path_str.c"
#include "../libretro-common/lists/dir_list.c"
#include "../libretro-common/lists/string_list.c"
#include "../libretro-common/lists/file_list.c"