mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 05:43:34 +00:00
Merge dirs.c into paths.c
This commit is contained in:
parent
5f2e3c283d
commit
3b634b64fa
@ -165,7 +165,6 @@ OBJ += frontend/frontend.o \
|
|||||||
ui/drivers/null/ui_null_msg_window.o \
|
ui/drivers/null/ui_null_msg_window.o \
|
||||||
ui/drivers/null/ui_null_application.o \
|
ui/drivers/null/ui_null_application.o \
|
||||||
retroarch.o \
|
retroarch.o \
|
||||||
dirs.o \
|
|
||||||
paths.o \
|
paths.o \
|
||||||
command.o \
|
command.o \
|
||||||
msg_hash.o \
|
msg_hash.o \
|
||||||
|
@ -81,7 +81,6 @@
|
|||||||
#include "performance_counters.h"
|
#include "performance_counters.h"
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
#include "content.h"
|
#include "content.h"
|
||||||
#include "dirs.h"
|
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
#include "retroarch.h"
|
#include "retroarch.h"
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include "led/led_defines.h"
|
#include "led/led_defines.h"
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "dirs.h"
|
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
#include "retroarch.h"
|
#include "retroarch.h"
|
||||||
#include "verbosity.h"
|
#include "verbosity.h"
|
||||||
|
324
dirs.c
324
dirs.c
@ -1,324 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2011-2017 - 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 <retro_miscellaneous.h>
|
|
||||||
#include <compat/strl.h>
|
|
||||||
#include <file/file_path.h>
|
|
||||||
#include <lists/dir_list.h>
|
|
||||||
#include <lists/string_list.h>
|
|
||||||
#include <string/stdstring.h>
|
|
||||||
#include <streams/file_stream.h>
|
|
||||||
#include <retro_assert.h>
|
|
||||||
|
|
||||||
#include "dirs.h"
|
|
||||||
#include "command.h"
|
|
||||||
#include "configuration.h"
|
|
||||||
#include "defaults.h"
|
|
||||||
#include "list_special.h"
|
|
||||||
#include "file_path_special.h"
|
|
||||||
#include "msg_hash.h"
|
|
||||||
#include "paths.h"
|
|
||||||
#include "content.h"
|
|
||||||
#include "retroarch.h"
|
|
||||||
#include "verbosity.h"
|
|
||||||
|
|
||||||
struct rarch_dir_list
|
|
||||||
{
|
|
||||||
struct string_list *list;
|
|
||||||
size_t ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rarch_dir_list dir_shader_list;
|
|
||||||
|
|
||||||
static char dir_system[PATH_MAX_LENGTH] = {0};
|
|
||||||
static char dir_savefile[PATH_MAX_LENGTH] = {0};
|
|
||||||
static char current_savefile_dir[PATH_MAX_LENGTH] = {0};
|
|
||||||
static char current_savestate_dir[PATH_MAX_LENGTH] = {0};
|
|
||||||
static char dir_savestate[PATH_MAX_LENGTH] = {0};
|
|
||||||
|
|
||||||
/* init functions */
|
|
||||||
|
|
||||||
bool dir_init_shader(void)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
struct rarch_dir_list *dir_list = (struct rarch_dir_list*)&dir_shader_list;
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
if (!settings || !*settings->paths.directory_video_shader)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
dir_list->list = dir_list_new_special(
|
|
||||||
settings->paths.directory_video_shader, DIR_LIST_SHADERS, NULL);
|
|
||||||
|
|
||||||
if (!dir_list->list || dir_list->list->size == 0)
|
|
||||||
{
|
|
||||||
command_event(CMD_EVENT_SHADER_DIR_DEINIT, NULL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dir_list->ptr = 0;
|
|
||||||
dir_list_sort(dir_list->list, false);
|
|
||||||
|
|
||||||
for (i = 0; i < dir_list->list->size; i++)
|
|
||||||
RARCH_LOG("%s \"%s\"\n",
|
|
||||||
msg_hash_to_str(MSG_FOUND_SHADER),
|
|
||||||
dir_list->list->elems[i].data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* free functions */
|
|
||||||
|
|
||||||
bool dir_free_shader(void)
|
|
||||||
{
|
|
||||||
struct rarch_dir_list *dir_list =
|
|
||||||
(struct rarch_dir_list*)&dir_shader_list;
|
|
||||||
|
|
||||||
dir_list_free(dir_list->list);
|
|
||||||
dir_list->list = NULL;
|
|
||||||
dir_list->ptr = 0;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check functions */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dir_check_shader:
|
|
||||||
* @pressed_next : was next shader key pressed?
|
|
||||||
* @pressed_previous : was previous shader key pressed?
|
|
||||||
*
|
|
||||||
* Checks if any one of the shader keys has been pressed for this frame:
|
|
||||||
* a) Next shader index.
|
|
||||||
* b) Previous shader index.
|
|
||||||
*
|
|
||||||
* Will also immediately apply the shader.
|
|
||||||
**/
|
|
||||||
void dir_check_shader(bool pressed_next, bool pressed_prev)
|
|
||||||
{
|
|
||||||
struct rarch_dir_list *dir_list = (struct rarch_dir_list*)&dir_shader_list;
|
|
||||||
static bool change_triggered = false;
|
|
||||||
|
|
||||||
if (!dir_list || !dir_list->list)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (pressed_next)
|
|
||||||
{
|
|
||||||
if (change_triggered)
|
|
||||||
dir_list->ptr = (dir_list->ptr + 1) %
|
|
||||||
dir_list->list->size;
|
|
||||||
}
|
|
||||||
else if (pressed_prev)
|
|
||||||
{
|
|
||||||
if (dir_list->ptr == 0)
|
|
||||||
dir_list->ptr = dir_list->list->size - 1;
|
|
||||||
else
|
|
||||||
dir_list->ptr--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
change_triggered = true;
|
|
||||||
|
|
||||||
command_set_shader(dir_list->list->elems[dir_list->ptr].data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* empty functions */
|
|
||||||
|
|
||||||
bool dir_is_empty(enum rarch_dir_type type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case RARCH_DIR_SYSTEM:
|
|
||||||
return string_is_empty(dir_system);
|
|
||||||
case RARCH_DIR_SAVEFILE:
|
|
||||||
return string_is_empty(dir_savefile);
|
|
||||||
case RARCH_DIR_CURRENT_SAVEFILE:
|
|
||||||
return string_is_empty(current_savefile_dir);
|
|
||||||
case RARCH_DIR_SAVESTATE:
|
|
||||||
return string_is_empty(dir_savestate);
|
|
||||||
case RARCH_DIR_CURRENT_SAVESTATE:
|
|
||||||
return string_is_empty(current_savestate_dir);
|
|
||||||
case RARCH_DIR_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get size functions */
|
|
||||||
|
|
||||||
size_t dir_get_size(enum rarch_dir_type type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case RARCH_DIR_SYSTEM:
|
|
||||||
return sizeof(dir_system);
|
|
||||||
case RARCH_DIR_SAVESTATE:
|
|
||||||
return sizeof(dir_savestate);
|
|
||||||
case RARCH_DIR_CURRENT_SAVESTATE:
|
|
||||||
return sizeof(current_savestate_dir);
|
|
||||||
case RARCH_DIR_SAVEFILE:
|
|
||||||
return sizeof(dir_savefile);
|
|
||||||
case RARCH_DIR_CURRENT_SAVEFILE:
|
|
||||||
return sizeof(current_savefile_dir);
|
|
||||||
case RARCH_DIR_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* clear functions */
|
|
||||||
|
|
||||||
void dir_clear(enum rarch_dir_type type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case RARCH_DIR_SAVEFILE:
|
|
||||||
*dir_savefile = '\0';
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_CURRENT_SAVEFILE:
|
|
||||||
*current_savefile_dir = '\0';
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_SAVESTATE:
|
|
||||||
*dir_savestate = '\0';
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_CURRENT_SAVESTATE:
|
|
||||||
*current_savestate_dir = '\0';
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_SYSTEM:
|
|
||||||
*dir_system = '\0';
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dir_clear_all(void)
|
|
||||||
{
|
|
||||||
dir_clear(RARCH_DIR_SYSTEM);
|
|
||||||
dir_clear(RARCH_DIR_SAVEFILE);
|
|
||||||
dir_clear(RARCH_DIR_SAVESTATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get ptr functions */
|
|
||||||
|
|
||||||
char *dir_get_ptr(enum rarch_dir_type type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case RARCH_DIR_SAVEFILE:
|
|
||||||
return dir_savefile;
|
|
||||||
case RARCH_DIR_CURRENT_SAVEFILE:
|
|
||||||
return current_savefile_dir;
|
|
||||||
case RARCH_DIR_SAVESTATE:
|
|
||||||
return dir_savestate;
|
|
||||||
case RARCH_DIR_CURRENT_SAVESTATE:
|
|
||||||
return current_savestate_dir;
|
|
||||||
case RARCH_DIR_SYSTEM:
|
|
||||||
return dir_system;
|
|
||||||
case RARCH_DIR_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *dir_get(enum rarch_dir_type type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case RARCH_DIR_SAVEFILE:
|
|
||||||
return dir_savefile;
|
|
||||||
case RARCH_DIR_CURRENT_SAVEFILE:
|
|
||||||
return current_savefile_dir;
|
|
||||||
case RARCH_DIR_SAVESTATE:
|
|
||||||
return dir_savestate;
|
|
||||||
case RARCH_DIR_CURRENT_SAVESTATE:
|
|
||||||
return current_savestate_dir;
|
|
||||||
case RARCH_DIR_SYSTEM:
|
|
||||||
return dir_system;
|
|
||||||
case RARCH_DIR_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dir_set(enum rarch_dir_type type, const char *path)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case RARCH_DIR_CURRENT_SAVEFILE:
|
|
||||||
strlcpy(current_savefile_dir, path,
|
|
||||||
sizeof(current_savefile_dir));
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_SAVEFILE:
|
|
||||||
strlcpy(dir_savefile, path,
|
|
||||||
sizeof(dir_savefile));
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_CURRENT_SAVESTATE:
|
|
||||||
strlcpy(current_savestate_dir, path,
|
|
||||||
sizeof(current_savestate_dir));
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_SAVESTATE:
|
|
||||||
strlcpy(dir_savestate, path,
|
|
||||||
sizeof(dir_savestate));
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_SYSTEM:
|
|
||||||
strlcpy(dir_system, path,
|
|
||||||
sizeof(dir_system));
|
|
||||||
break;
|
|
||||||
case RARCH_DIR_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dir_check_defaults(void)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
/* early return for people with a custom folder setup
|
|
||||||
so it doesn't create unnecessary directories
|
|
||||||
*/
|
|
||||||
#if defined(ORBIS) || defined(ANDROID)
|
|
||||||
if (path_is_valid("host0:app/custom.ini"))
|
|
||||||
#else
|
|
||||||
if (path_is_valid("custom.ini"))
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < DEFAULT_DIR_LAST; i++)
|
|
||||||
{
|
|
||||||
char *new_path = NULL;
|
|
||||||
const char *dir_path = g_defaults.dirs[i];
|
|
||||||
|
|
||||||
if (string_is_empty(dir_path))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
new_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
|
|
||||||
if (!new_path)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
new_path[0] = '\0';
|
|
||||||
fill_pathname_expand_special(new_path,
|
|
||||||
dir_path,
|
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
|
|
||||||
if (!path_is_directory(new_path))
|
|
||||||
path_mkdir(new_path);
|
|
||||||
|
|
||||||
free(new_path);
|
|
||||||
}
|
|
||||||
}
|
|
58
dirs.h
58
dirs.h
@ -1,58 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2011-2017 - 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __DIRS_H
|
|
||||||
#define __DIRS_H
|
|
||||||
|
|
||||||
#include <boolean.h>
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
enum rarch_dir_type
|
|
||||||
{
|
|
||||||
RARCH_DIR_NONE = 0,
|
|
||||||
RARCH_DIR_SAVEFILE,
|
|
||||||
RARCH_DIR_SAVESTATE,
|
|
||||||
RARCH_DIR_CURRENT_SAVEFILE,
|
|
||||||
RARCH_DIR_CURRENT_SAVESTATE,
|
|
||||||
RARCH_DIR_SYSTEM
|
|
||||||
};
|
|
||||||
|
|
||||||
bool dir_init_shader(void);
|
|
||||||
|
|
||||||
bool dir_free_shader(void);
|
|
||||||
|
|
||||||
void dir_check_shader(bool pressed_next, bool pressed_prev);
|
|
||||||
|
|
||||||
bool dir_is_empty(enum rarch_dir_type type);
|
|
||||||
|
|
||||||
void dir_clear(enum rarch_dir_type type);
|
|
||||||
|
|
||||||
void dir_clear_all(void);
|
|
||||||
|
|
||||||
size_t dir_get_size(enum rarch_dir_type type);
|
|
||||||
|
|
||||||
char *dir_get_ptr(enum rarch_dir_type type);
|
|
||||||
|
|
||||||
const char *dir_get(enum rarch_dir_type type);
|
|
||||||
|
|
||||||
void dir_set(enum rarch_dir_type type, const char *path);
|
|
||||||
|
|
||||||
void dir_check_defaults(void);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
@ -59,7 +59,6 @@
|
|||||||
|
|
||||||
#include "cores/internal_cores.h"
|
#include "cores/internal_cores.h"
|
||||||
#include "content.h"
|
#include "content.h"
|
||||||
#include "dirs.h"
|
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
#include "retroarch.h"
|
#include "retroarch.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
@ -1071,7 +1071,6 @@ GIT
|
|||||||
RETROARCH
|
RETROARCH
|
||||||
============================================================ */
|
============================================================ */
|
||||||
#include "../retroarch.c"
|
#include "../retroarch.c"
|
||||||
#include "../dirs.c"
|
|
||||||
#include "../paths.c"
|
#include "../paths.c"
|
||||||
#include "../libretro-common/queues/task_queue.c"
|
#include "../libretro-common/queues/task_queue.c"
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@
|
|||||||
#include "../msg_hash.h"
|
#include "../msg_hash.h"
|
||||||
#include "../defaults.h"
|
#include "../defaults.h"
|
||||||
#include "../driver.h"
|
#include "../driver.h"
|
||||||
#include "../dirs.h"
|
|
||||||
#include "../paths.h"
|
#include "../paths.h"
|
||||||
#include "../dynamic.h"
|
#include "../dynamic.h"
|
||||||
#include "../list_special.h"
|
#include "../list_special.h"
|
||||||
|
295
paths.c
295
paths.c
@ -1,5 +1,5 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
/* RetroArch - A frontend for libretro.
|
||||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
* Copyright (C) 2011-2019 - Daniel De Matteis
|
||||||
* Copyright (C) 2017-2019 - Andrés Suárez
|
* Copyright (C) 2017-2019 - Andrés Suárez
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
@ -17,8 +17,10 @@
|
|||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
|
#include <lists/dir_list.h>
|
||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
#include <streams/file_stream.h>
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -29,14 +31,15 @@
|
|||||||
#include "network/netplay/netplay.h"
|
#include "network/netplay/netplay.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dirs.h"
|
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "content.h"
|
#include "content.h"
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
|
#include "defaults.h"
|
||||||
#include "file_path_special.h"
|
#include "file_path_special.h"
|
||||||
|
#include "list_special.h"
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
@ -46,6 +49,12 @@
|
|||||||
|
|
||||||
#define MENU_VALUE_NO_CORE 0x7d5472cbU
|
#define MENU_VALUE_NO_CORE 0x7d5472cbU
|
||||||
|
|
||||||
|
struct rarch_dir_list
|
||||||
|
{
|
||||||
|
struct string_list *list;
|
||||||
|
size_t ptr;
|
||||||
|
};
|
||||||
|
|
||||||
static struct string_list *subsystem_fullpaths = NULL;
|
static struct string_list *subsystem_fullpaths = NULL;
|
||||||
|
|
||||||
static char subsystem_path[PATH_MAX_LENGTH] = {0};
|
static char subsystem_path[PATH_MAX_LENGTH] = {0};
|
||||||
@ -57,6 +66,15 @@ static char path_config_file[PATH_MAX_LENGTH] = {0};
|
|||||||
static char path_config_append_file[PATH_MAX_LENGTH] = {0};
|
static char path_config_append_file[PATH_MAX_LENGTH] = {0};
|
||||||
static char path_core_options_file[PATH_MAX_LENGTH] = {0};
|
static char path_core_options_file[PATH_MAX_LENGTH] = {0};
|
||||||
|
|
||||||
|
static struct rarch_dir_list dir_shader_list;
|
||||||
|
|
||||||
|
static char dir_system[PATH_MAX_LENGTH] = {0};
|
||||||
|
static char dir_savefile[PATH_MAX_LENGTH] = {0};
|
||||||
|
static char current_savefile_dir[PATH_MAX_LENGTH] = {0};
|
||||||
|
static char current_savestate_dir[PATH_MAX_LENGTH] = {0};
|
||||||
|
static char dir_savestate[PATH_MAX_LENGTH] = {0};
|
||||||
|
|
||||||
|
|
||||||
void path_set_redirect(void)
|
void path_set_redirect(void)
|
||||||
{
|
{
|
||||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||||
@ -787,3 +805,276 @@ void path_deinit_subsystem(void)
|
|||||||
string_list_free(subsystem_fullpaths);
|
string_list_free(subsystem_fullpaths);
|
||||||
subsystem_fullpaths = NULL;
|
subsystem_fullpaths = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dir_init_shader(void)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
struct rarch_dir_list *dir_list = (struct rarch_dir_list*)&dir_shader_list;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (!settings || !*settings->paths.directory_video_shader)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
dir_list->list = dir_list_new_special(
|
||||||
|
settings->paths.directory_video_shader, DIR_LIST_SHADERS, NULL);
|
||||||
|
|
||||||
|
if (!dir_list->list || dir_list->list->size == 0)
|
||||||
|
{
|
||||||
|
command_event(CMD_EVENT_SHADER_DIR_DEINIT, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dir_list->ptr = 0;
|
||||||
|
dir_list_sort(dir_list->list, false);
|
||||||
|
|
||||||
|
for (i = 0; i < dir_list->list->size; i++)
|
||||||
|
RARCH_LOG("%s \"%s\"\n",
|
||||||
|
msg_hash_to_str(MSG_FOUND_SHADER),
|
||||||
|
dir_list->list->elems[i].data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free functions */
|
||||||
|
|
||||||
|
bool dir_free_shader(void)
|
||||||
|
{
|
||||||
|
struct rarch_dir_list *dir_list =
|
||||||
|
(struct rarch_dir_list*)&dir_shader_list;
|
||||||
|
|
||||||
|
dir_list_free(dir_list->list);
|
||||||
|
dir_list->list = NULL;
|
||||||
|
dir_list->ptr = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check functions */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dir_check_shader:
|
||||||
|
* @pressed_next : was next shader key pressed?
|
||||||
|
* @pressed_previous : was previous shader key pressed?
|
||||||
|
*
|
||||||
|
* Checks if any one of the shader keys has been pressed for this frame:
|
||||||
|
* a) Next shader index.
|
||||||
|
* b) Previous shader index.
|
||||||
|
*
|
||||||
|
* Will also immediately apply the shader.
|
||||||
|
**/
|
||||||
|
void dir_check_shader(bool pressed_next, bool pressed_prev)
|
||||||
|
{
|
||||||
|
struct rarch_dir_list *dir_list = (struct rarch_dir_list*)&dir_shader_list;
|
||||||
|
static bool change_triggered = false;
|
||||||
|
|
||||||
|
if (!dir_list || !dir_list->list)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (pressed_next)
|
||||||
|
{
|
||||||
|
if (change_triggered)
|
||||||
|
dir_list->ptr = (dir_list->ptr + 1) %
|
||||||
|
dir_list->list->size;
|
||||||
|
}
|
||||||
|
else if (pressed_prev)
|
||||||
|
{
|
||||||
|
if (dir_list->ptr == 0)
|
||||||
|
dir_list->ptr = dir_list->list->size - 1;
|
||||||
|
else
|
||||||
|
dir_list->ptr--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
change_triggered = true;
|
||||||
|
|
||||||
|
command_set_shader(dir_list->list->elems[dir_list->ptr].data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* empty functions */
|
||||||
|
|
||||||
|
bool dir_is_empty(enum rarch_dir_type type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case RARCH_DIR_SYSTEM:
|
||||||
|
return string_is_empty(dir_system);
|
||||||
|
case RARCH_DIR_SAVEFILE:
|
||||||
|
return string_is_empty(dir_savefile);
|
||||||
|
case RARCH_DIR_CURRENT_SAVEFILE:
|
||||||
|
return string_is_empty(current_savefile_dir);
|
||||||
|
case RARCH_DIR_SAVESTATE:
|
||||||
|
return string_is_empty(dir_savestate);
|
||||||
|
case RARCH_DIR_CURRENT_SAVESTATE:
|
||||||
|
return string_is_empty(current_savestate_dir);
|
||||||
|
case RARCH_DIR_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get size functions */
|
||||||
|
|
||||||
|
size_t dir_get_size(enum rarch_dir_type type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case RARCH_DIR_SYSTEM:
|
||||||
|
return sizeof(dir_system);
|
||||||
|
case RARCH_DIR_SAVESTATE:
|
||||||
|
return sizeof(dir_savestate);
|
||||||
|
case RARCH_DIR_CURRENT_SAVESTATE:
|
||||||
|
return sizeof(current_savestate_dir);
|
||||||
|
case RARCH_DIR_SAVEFILE:
|
||||||
|
return sizeof(dir_savefile);
|
||||||
|
case RARCH_DIR_CURRENT_SAVEFILE:
|
||||||
|
return sizeof(current_savefile_dir);
|
||||||
|
case RARCH_DIR_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clear functions */
|
||||||
|
|
||||||
|
void dir_clear(enum rarch_dir_type type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case RARCH_DIR_SAVEFILE:
|
||||||
|
*dir_savefile = '\0';
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_CURRENT_SAVEFILE:
|
||||||
|
*current_savefile_dir = '\0';
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_SAVESTATE:
|
||||||
|
*dir_savestate = '\0';
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_CURRENT_SAVESTATE:
|
||||||
|
*current_savestate_dir = '\0';
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_SYSTEM:
|
||||||
|
*dir_system = '\0';
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dir_clear_all(void)
|
||||||
|
{
|
||||||
|
dir_clear(RARCH_DIR_SYSTEM);
|
||||||
|
dir_clear(RARCH_DIR_SAVEFILE);
|
||||||
|
dir_clear(RARCH_DIR_SAVESTATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get ptr functions */
|
||||||
|
|
||||||
|
char *dir_get_ptr(enum rarch_dir_type type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case RARCH_DIR_SAVEFILE:
|
||||||
|
return dir_savefile;
|
||||||
|
case RARCH_DIR_CURRENT_SAVEFILE:
|
||||||
|
return current_savefile_dir;
|
||||||
|
case RARCH_DIR_SAVESTATE:
|
||||||
|
return dir_savestate;
|
||||||
|
case RARCH_DIR_CURRENT_SAVESTATE:
|
||||||
|
return current_savestate_dir;
|
||||||
|
case RARCH_DIR_SYSTEM:
|
||||||
|
return dir_system;
|
||||||
|
case RARCH_DIR_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dir_get(enum rarch_dir_type type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case RARCH_DIR_SAVEFILE:
|
||||||
|
return dir_savefile;
|
||||||
|
case RARCH_DIR_CURRENT_SAVEFILE:
|
||||||
|
return current_savefile_dir;
|
||||||
|
case RARCH_DIR_SAVESTATE:
|
||||||
|
return dir_savestate;
|
||||||
|
case RARCH_DIR_CURRENT_SAVESTATE:
|
||||||
|
return current_savestate_dir;
|
||||||
|
case RARCH_DIR_SYSTEM:
|
||||||
|
return dir_system;
|
||||||
|
case RARCH_DIR_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dir_set(enum rarch_dir_type type, const char *path)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case RARCH_DIR_CURRENT_SAVEFILE:
|
||||||
|
strlcpy(current_savefile_dir, path,
|
||||||
|
sizeof(current_savefile_dir));
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_SAVEFILE:
|
||||||
|
strlcpy(dir_savefile, path,
|
||||||
|
sizeof(dir_savefile));
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_CURRENT_SAVESTATE:
|
||||||
|
strlcpy(current_savestate_dir, path,
|
||||||
|
sizeof(current_savestate_dir));
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_SAVESTATE:
|
||||||
|
strlcpy(dir_savestate, path,
|
||||||
|
sizeof(dir_savestate));
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_SYSTEM:
|
||||||
|
strlcpy(dir_system, path,
|
||||||
|
sizeof(dir_system));
|
||||||
|
break;
|
||||||
|
case RARCH_DIR_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dir_check_defaults(void)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
/* early return for people with a custom folder setup
|
||||||
|
so it doesn't create unnecessary directories
|
||||||
|
*/
|
||||||
|
#if defined(ORBIS) || defined(ANDROID)
|
||||||
|
if (path_is_valid("host0:app/custom.ini"))
|
||||||
|
#else
|
||||||
|
if (path_is_valid("custom.ini"))
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < DEFAULT_DIR_LAST; i++)
|
||||||
|
{
|
||||||
|
char *new_path = NULL;
|
||||||
|
const char *dir_path = g_defaults.dirs[i];
|
||||||
|
|
||||||
|
if (string_is_empty(dir_path))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
new_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||||
|
|
||||||
|
if (!new_path)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
new_path[0] = '\0';
|
||||||
|
fill_pathname_expand_special(new_path,
|
||||||
|
dir_path,
|
||||||
|
PATH_MAX_LENGTH * sizeof(char));
|
||||||
|
|
||||||
|
if (!path_is_directory(new_path))
|
||||||
|
path_mkdir(new_path);
|
||||||
|
|
||||||
|
free(new_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
35
paths.h
35
paths.h
@ -1,5 +1,5 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
/* RetroArch - A frontend for libretro.
|
||||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
* Copyright (C) 2011-2019 - Daniel De Matteis
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* 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-
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
@ -23,6 +23,16 @@
|
|||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
enum rarch_dir_type
|
||||||
|
{
|
||||||
|
RARCH_DIR_NONE = 0,
|
||||||
|
RARCH_DIR_SAVEFILE,
|
||||||
|
RARCH_DIR_SAVESTATE,
|
||||||
|
RARCH_DIR_CURRENT_SAVEFILE,
|
||||||
|
RARCH_DIR_CURRENT_SAVESTATE,
|
||||||
|
RARCH_DIR_SYSTEM
|
||||||
|
};
|
||||||
|
|
||||||
enum rarch_content_type
|
enum rarch_content_type
|
||||||
{
|
{
|
||||||
RARCH_CONTENT_NONE = 0,
|
RARCH_CONTENT_NONE = 0,
|
||||||
@ -46,6 +56,29 @@ enum rarch_path_type
|
|||||||
RARCH_PATH_SUBSYSTEM
|
RARCH_PATH_SUBSYSTEM
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool dir_init_shader(void);
|
||||||
|
|
||||||
|
bool dir_free_shader(void);
|
||||||
|
|
||||||
|
void dir_check_shader(bool pressed_next, bool pressed_prev);
|
||||||
|
|
||||||
|
bool dir_is_empty(enum rarch_dir_type type);
|
||||||
|
|
||||||
|
void dir_clear(enum rarch_dir_type type);
|
||||||
|
|
||||||
|
void dir_clear_all(void);
|
||||||
|
|
||||||
|
size_t dir_get_size(enum rarch_dir_type type);
|
||||||
|
|
||||||
|
char *dir_get_ptr(enum rarch_dir_type type);
|
||||||
|
|
||||||
|
const char *dir_get(enum rarch_dir_type type);
|
||||||
|
|
||||||
|
void dir_set(enum rarch_dir_type type, const char *path);
|
||||||
|
|
||||||
|
void dir_check_defaults(void);
|
||||||
|
|
||||||
void path_deinit_subsystem(void);
|
void path_deinit_subsystem(void);
|
||||||
|
|
||||||
void path_deinit_savefile(void);
|
void path_deinit_savefile(void);
|
||||||
|
@ -133,7 +133,6 @@
|
|||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include "input/input_driver.h"
|
#include "input/input_driver.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
#include "dirs.h"
|
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
#include "file_path_special.h"
|
#include "file_path_special.h"
|
||||||
#include "ui/ui_companion_driver.h"
|
#include "ui/ui_companion_driver.h"
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
#include "file_path_special.h"
|
#include "file_path_special.h"
|
||||||
#include "dirs.h"
|
#include "paths.h"
|
||||||
#include "core_info.h"
|
#include "core_info.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "verbosity.h"
|
#include "verbosity.h"
|
||||||
|
@ -94,7 +94,6 @@
|
|||||||
#include "../retroarch.h"
|
#include "../retroarch.h"
|
||||||
#include "../file_path_special.h"
|
#include "../file_path_special.h"
|
||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
#include "../dirs.h"
|
|
||||||
#include "../paths.h"
|
#include "../paths.h"
|
||||||
#include "../verbosity.h"
|
#include "../verbosity.h"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user