Add record dirs to dirs.c

This commit is contained in:
twinaphex 2016-09-30 07:45:04 +02:00
parent 0e3fbb615e
commit fe3281e05d
8 changed files with 64 additions and 27 deletions

View File

@ -575,7 +575,6 @@ static int populate_settings_path(settings_t *settings, struct config_path_setti
{
unsigned count = 0;
struct config_path_setting *tmp = NULL;
global_t *global = global_get_ptr();
/* Paths */
#ifdef HAVE_XMB
@ -590,9 +589,9 @@ static int populate_settings_path(settings_t *settings, struct config_path_setti
SETTING_PATH("netplay_ip_address", path_get_ptr(RARCH_PATH_SERVER), false, NULL, true);
#endif
SETTING_PATH("recording_output_directory",
global->record.output_dir, false, NULL, true);
dir_get_ptr(RARCH_DIR_RECORD_OUTPUT), false, NULL, true);
SETTING_PATH("recording_config_directory",
global->record.config_dir, false, NULL, true);
dir_get_ptr(RARCH_DIR_RECORD_CONFIG), false, NULL, true);
SETTING_PATH("libretro_directory",
settings->directory.libretro, false, NULL, false);
SETTING_PATH("core_options_path",
@ -1178,8 +1177,8 @@ static void config_set_defaults(void)
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF))
rarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);
*global->record.output_dir = '\0';
*global->record.config_dir = '\0';
dir_clear(RARCH_DIR_RECORD_OUTPUT);
dir_clear(RARCH_DIR_RECORD_CONFIG);
*settings->path.core_options = '\0';
*settings->path.content_history = '\0';

42
dirs.c
View File

@ -40,10 +40,12 @@ struct rarch_dir_list
static struct rarch_dir_list dir_shader_list;
static char dir_osk_overlay[PATH_MAX_LENGTH] = {0};
static char dir_system[PATH_MAX_LENGTH] = {0};
static char dir_savefile[PATH_MAX_LENGTH] = {0};
static char dir_savestate[PATH_MAX_LENGTH] = {0};
static char dir_record_output[PATH_MAX_LENGTH] = {0};
static char dir_record_config[PATH_MAX_LENGTH] = {0};
static char dir_osk_overlay[PATH_MAX_LENGTH] = {0};
static char dir_system[PATH_MAX_LENGTH] = {0};
static char dir_savefile[PATH_MAX_LENGTH] = {0};
static char dir_savestate[PATH_MAX_LENGTH] = {0};
static bool shader_dir_init(struct rarch_dir_list *dir_list)
{
@ -172,6 +174,10 @@ bool dir_is_empty(enum rarch_dir_type type)
{
switch (type)
{
case RARCH_DIR_RECORD_OUTPUT:
return string_is_empty(dir_record_output);
case RARCH_DIR_RECORD_CONFIG:
return string_is_empty(dir_record_config);
case RARCH_DIR_SYSTEM:
return string_is_empty(dir_system);
case RARCH_DIR_SAVEFILE:
@ -190,10 +196,14 @@ bool dir_is_empty(enum rarch_dir_type type)
/* get size functions */
size_t dir_get_size(enum rarch_dir_type type)
size_t dir_get_ptr_size(enum rarch_dir_type type)
{
switch (type)
{
case RARCH_DIR_RECORD_OUTPUT:
return sizeof(dir_record_output);
case RARCH_DIR_RECORD_CONFIG:
return sizeof(dir_record_config);
case RARCH_DIR_SYSTEM:
return sizeof(dir_system);
case RARCH_DIR_SAVEFILE:
@ -216,6 +226,12 @@ void dir_clear(enum rarch_dir_type type)
{
switch (type)
{
case RARCH_DIR_RECORD_OUTPUT:
*dir_record_output = '\0';
break;
case RARCH_DIR_RECORD_CONFIG:
*dir_record_config = '\0';
break;
case RARCH_DIR_SYSTEM:
*dir_system = '\0';
break;
@ -248,6 +264,10 @@ char *dir_get_ptr(enum rarch_dir_type type)
{
switch (type)
{
case RARCH_DIR_RECORD_OUTPUT:
return dir_record_output;
case RARCH_DIR_RECORD_CONFIG:
return dir_record_config;
case RARCH_DIR_SYSTEM:
return dir_system;
case RARCH_DIR_SAVEFILE:
@ -270,6 +290,10 @@ const char *dir_get(enum rarch_dir_type type)
{
switch (type)
{
case RARCH_DIR_RECORD_OUTPUT:
return dir_record_output;
case RARCH_DIR_RECORD_CONFIG:
return dir_record_config;
case RARCH_DIR_OSK_OVERLAY:
return dir_osk_overlay;
case RARCH_DIR_SYSTEM:
@ -292,6 +316,14 @@ void dir_set(enum rarch_dir_type type, const char *path)
{
switch (type)
{
case RARCH_DIR_RECORD_OUTPUT:
strlcpy(dir_record_output, path,
sizeof(dir_record_output));
break;
case RARCH_DIR_RECORD_CONFIG:
strlcpy(dir_record_config, path,
sizeof(dir_record_config));
break;
case RARCH_DIR_OSK_OVERLAY:
strlcpy(dir_osk_overlay, path,
sizeof(dir_osk_overlay));

6
dirs.h
View File

@ -27,7 +27,9 @@ enum rarch_dir_type
RARCH_DIR_SYSTEM,
RARCH_DIR_SAVEFILE,
RARCH_DIR_SAVESTATE,
RARCH_DIR_OSK_OVERLAY
RARCH_DIR_OSK_OVERLAY,
RARCH_DIR_RECORD_OUTPUT,
RARCH_DIR_RECORD_CONFIG
};
bool dir_init_shader(void);
@ -42,7 +44,7 @@ void dir_clear(enum rarch_dir_type type);
void dir_clear_all(void);
size_t dir_get_size(enum rarch_dir_type type);
size_t dir_get_ptr_size(enum rarch_dir_type type);
char *dir_get_ptr(enum rarch_dir_type type);

View File

@ -43,6 +43,7 @@
#include "../../managers/cheat_manager.h"
#include "../../tasks/tasks_internal.h"
#include "../../input/input_remapping.h"
#include "../../dirs.h"
#include "../../paths.h"
#include "../../retroarch.h"
#include "../../runloop.h"
@ -351,7 +352,7 @@ int generic_action_ok_displaylist_push(const char *path,
menu_displaylist_reset_filebrowser();
info.type = type;
info.directory_ptr = idx;
info_path = global->record.config_dir;
info_path = dir_get(RARCH_DIR_RECORD_CONFIG);
info_label = label;
dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE;
}

View File

@ -6467,8 +6467,8 @@ static bool setting_append_list(
{
CONFIG_DIR(
list, list_info,
global->record.output_dir,
sizeof(global->record.output_dir),
dir_get_ptr(RARCH_DIR_RECORD_OUTPUT),
dir_get_ptr_size(RARCH_DIR_RECORD_OUTPUT),
msg_hash_to_str(MENU_ENUM_LABEL_RECORDING_OUTPUT_DIRECTORY),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RECORDING_OUTPUT_DIRECTORY),
"",
@ -6482,8 +6482,8 @@ static bool setting_append_list(
CONFIG_DIR(
list, list_info,
global->record.config_dir,
sizeof(global->record.config_dir),
dir_get_ptr(RARCH_DIR_RECORD_CONFIG),
dir_get_ptr_size(RARCH_DIR_RECORD_CONFIG),
msg_hash_to_str(MENU_ENUM_LABEL_RECORDING_CONFIG_DIRECTORY),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RECORDING_CONFIG_DIRECTORY),
"",
@ -6514,7 +6514,7 @@ static bool setting_append_list(
CONFIG_DIR(
list, list_info,
dir_get_ptr(RARCH_DIR_OSK_OVERLAY),
dir_get_size(RARCH_DIR_OSK_OVERLAY),
dir_get_ptr_size(RARCH_DIR_OSK_OVERLAY),
msg_hash_to_str(MENU_ENUM_LABEL_OSK_OVERLAY_DIRECTORY),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OSK_OVERLAY_DIRECTORY),
g_defaults.dir.osk_overlay,
@ -6590,7 +6590,7 @@ static bool setting_append_list(
CONFIG_DIR(
list, list_info,
dir_get_ptr(RARCH_DIR_SAVEFILE),
dir_get_size(RARCH_DIR_SAVEFILE),
dir_get_ptr_size(RARCH_DIR_SAVEFILE),
msg_hash_to_str(MENU_ENUM_LABEL_SAVEFILE_DIRECTORY),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVEFILE_DIRECTORY),
"",
@ -6605,7 +6605,7 @@ static bool setting_append_list(
CONFIG_DIR(
list, list_info,
dir_get_ptr(RARCH_DIR_SAVESTATE),
dir_get_size(RARCH_DIR_SAVESTATE),
dir_get_ptr_size(RARCH_DIR_SAVESTATE),
msg_hash_to_str(MENU_ENUM_LABEL_SAVESTATE_DIRECTORY),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVESTATE_DIRECTORY),
"",

View File

@ -33,6 +33,7 @@
#include "../runloop.h"
#include "../verbosity.h"
#include "../msg_hash.h"
#include "../dirs.h"
#include "../paths.h"
#include "../list_special.h"
@ -332,7 +333,7 @@ bool recording_init(void)
if (global->record.use_output_dir)
fill_pathname_join(recording_file,
global->record.output_dir,
dir_get(RARCH_DIR_RECORD_OUTPUT),
path_get(RARCH_PATH_RECORD),
sizeof(recording_file));

View File

@ -728,7 +728,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
break;
case RUNLOOP_CTL_GLOBAL_FREE:
{
global_t *global = NULL;
command_event(CMD_EVENT_TEMPORARY_CONTENT_DEINIT, NULL);
path_deinit_subsystem();
@ -758,10 +757,16 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
core_unset_input_descriptors();
global = global_get_ptr();
path_clear_all();
dir_clear(RARCH_DIR_RECORD_CONFIG);
dir_clear(RARCH_DIR_RECORD_OUTPUT);
dir_clear_all();
memset(global, 0, sizeof(struct global));
{
global_t *global = global_get_ptr();
memset(global, 0, sizeof(struct global));
}
retroarch_override_setting_free_state();
}
break;

View File

@ -158,9 +158,6 @@ typedef struct global
/* Recording. */
struct
{
char output_dir[PATH_MAX_LENGTH];
char config_dir[PATH_MAX_LENGTH];
unsigned width;
unsigned height;