Merge pull request #3448 from bparker06/hidden_files

add configuration option to toggle showing hidden files (default on)
This commit is contained in:
Twinaphex 2016-08-28 04:05:28 +02:00 committed by GitHub
commit 754cc1feed
15 changed files with 76 additions and 15 deletions

View File

@ -247,7 +247,7 @@ rarch_dsp_filter_t *rarch_dsp_filter_new(
if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name))) if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name)))
goto error; goto error;
plugs = dir_list_new(basedir, ext_name, false, false, false); plugs = dir_list_new(basedir, ext_name, false, true, false, false);
if (!plugs) if (!plugs)
goto error; goto error;
#endif #endif

View File

@ -511,6 +511,8 @@ static unsigned aspect_ratio_idx = ASPECT_RATIO_CORE;
/* Save configuration file on exit. */ /* Save configuration file on exit. */
static bool config_save_on_exit = true; static bool config_save_on_exit = true;
static bool show_hidden_files = true;
static const bool overlay_hide_in_menu = true; static const bool overlay_hide_in_menu = true;
#ifdef HAVE_MENU #ifdef HAVE_MENU

View File

@ -965,6 +965,7 @@ static void config_set_defaults(void)
g_defaults.path.config, sizeof(global->path.config)); g_defaults.path.config, sizeof(global->path.config));
settings->config_save_on_exit = config_save_on_exit; settings->config_save_on_exit = config_save_on_exit;
settings->show_hidden_files = show_hidden_files;
/* Avoid reloading config on every content load */ /* Avoid reloading config on every content load */
if (default_block_config_read) if (default_block_config_read)
@ -1314,6 +1315,7 @@ static bool config_load_file(const char *path, bool set_defaults,
{ "sort_savefiles_enable", &settings->sort_savefiles_enable}, { "sort_savefiles_enable", &settings->sort_savefiles_enable},
{ "sort_savestates_enable", &settings->sort_savestates_enable}, { "sort_savestates_enable", &settings->sort_savestates_enable},
{ "config_save_on_exit", &settings->config_save_on_exit}, { "config_save_on_exit", &settings->config_save_on_exit},
{ "show_hidden_files", &settings->show_hidden_files},
#ifdef HAVE_MENU #ifdef HAVE_MENU
{ "dpi_override_enable", &settings->menu.dpi.override_enable}, { "dpi_override_enable", &settings->menu.dpi.override_enable},
#endif #endif
@ -2921,6 +2923,7 @@ int populate_settings_bool(settings_t *settings, struct config_bool_setting *out
{ "sort_savefiles_enable", settings->sort_savefiles_enable}, { "sort_savefiles_enable", settings->sort_savefiles_enable},
{ "sort_savestates_enable", settings->sort_savestates_enable}, { "sort_savestates_enable", settings->sort_savestates_enable},
{ "config_save_on_exit", settings->config_save_on_exit}, { "config_save_on_exit", settings->config_save_on_exit},
{ "show_hidden_files", settings->show_hidden_files},
{ "input_autodetect_enable", settings->input.autodetect_enable}, { "input_autodetect_enable", settings->input.autodetect_enable},
{ "audio_rate_control", settings->audio.rate_control} { "audio_rate_control", settings->audio.rate_control}
}; };

View File

@ -495,6 +495,7 @@ typedef struct settings
#endif #endif
bool config_save_on_exit; bool config_save_on_exit;
bool show_hidden_files;
#ifdef HAVE_LAKKA #ifdef HAVE_LAKKA
bool ssh_enable; bool ssh_enable;

View File

@ -240,7 +240,7 @@ bool IMAGE_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info)
path_basedir(dir); path_basedir(dir);
file_list = dir_list_new(dir, IMAGE_CORE_PREFIX(valid_extensions), file_list = dir_list_new(dir, IMAGE_CORE_PREFIX(valid_extensions),
false,false,false); false,true,false,false);
dir_list_sort(file_list, false); dir_list_sort(file_list, false);
free(dir); free(dir);

View File

@ -366,7 +366,7 @@ static void *gfx_ctx_drm_init(void *video_driver)
return NULL; return NULL;
fd = -1; fd = -1;
gpu_descriptors = dir_list_new("/dev/dri", NULL, false, false, false); gpu_descriptors = dir_list_new("/dev/dri", NULL, false, true, false, false);
nextgpu: nextgpu:
free_drm_resources(drm); free_drm_resources(drm);

View File

@ -409,7 +409,7 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_config,
if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name))) if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name)))
goto error; goto error;
plugs = dir_list_new(basedir, ext_name, false, false, false); plugs = dir_list_new(basedir, ext_name, false, false, false, false);
if (!plugs) if (!plugs)
{ {

View File

@ -991,6 +991,10 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len)
#endif #endif
); );
break; break;
case MENU_ENUM_LABEL_SHOW_HIDDEN_FILES:
snprintf(s, len, "Show hidden files\n"
"and folders.");
break;
case MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS: case MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS:
snprintf(s, len, snprintf(s, len,
"Hardware filter for this pass. \n" "Hardware filter for this pass. \n"
@ -2518,6 +2522,8 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg)
return "auto_overrides_enable"; return "auto_overrides_enable";
case MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT: case MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT:
return "config_save_on_exit"; return "config_save_on_exit";
case MENU_ENUM_LABEL_SHOW_HIDDEN_FILES:
return "show_hidden_files";
case MENU_ENUM_LABEL_VIDEO_SMOOTH: case MENU_ENUM_LABEL_VIDEO_SMOOTH:
return "video_smooth"; return "video_smooth";
case MENU_ENUM_LABEL_VIDEO_GAMMA: case MENU_ENUM_LABEL_VIDEO_GAMMA:
@ -3841,6 +3847,8 @@ const char *msg_hash_to_str_us(enum msg_hash_enums msg)
return "Load Override Files Automatically"; return "Load Override Files Automatically";
case MENU_ENUM_LABEL_VALUE_CONFIG_SAVE_ON_EXIT: case MENU_ENUM_LABEL_VALUE_CONFIG_SAVE_ON_EXIT:
return "Save Configuration On Exit"; return "Save Configuration On Exit";
case MENU_ENUM_LABEL_VALUE_SHOW_HIDDEN_FILES:
return "Show Hidden Files and Folders";
case MENU_ENUM_LABEL_VALUE_VIDEO_SMOOTH: case MENU_ENUM_LABEL_VALUE_VIDEO_SMOOTH:
return "HW Bilinear Filtering"; return "HW Bilinear Filtering";
case MENU_ENUM_LABEL_VALUE_VIDEO_GAMMA: case MENU_ENUM_LABEL_VALUE_VIDEO_GAMMA:

View File

@ -34,6 +34,7 @@ RETRO_BEGIN_DECLS
* @dir : directory path. * @dir : directory path.
* @ext : allowed extensions of file directory entries to include. * @ext : allowed extensions of file directory entries to include.
* @include_dirs : include directories as part of the finished directory listing? * @include_dirs : include directories as part of the finished directory listing?
* @include_hidden : include hidden files and directories as part of the finished directory listing?
* @include_compressed : include compressed files, even when not part of ext. * @include_compressed : include compressed files, even when not part of ext.
* @recursive : list directory contents recursively * @recursive : list directory contents recursively
* *
@ -43,7 +44,7 @@ RETRO_BEGIN_DECLS
* NULL in case of error. Has to be freed manually. * NULL in case of error. Has to be freed manually.
**/ **/
struct string_list *dir_list_new(const char *dir, const char *ext, struct string_list *dir_list_new(const char *dir, const char *ext,
bool include_dirs, bool include_compressed, bool recursive); bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
/** /**
* dir_list_sort: * dir_list_sort:
@ -70,6 +71,7 @@ void dir_list_free(struct string_list *list);
* @list : the string list to add files to * @list : the string list to add files to
* @ext_list : the string list of extensions to include * @ext_list : the string list of extensions to include
* @include_dirs : include directories as part of the finished directory listing? * @include_dirs : include directories as part of the finished directory listing?
* @include_hidden : include hidden files and directories as part of the finished directory listing?
* @include_compressed : Only include files which match ext. Do not try to match compressed files, etc. * @include_compressed : Only include files which match ext. Do not try to match compressed files, etc.
* @recursive : list directory contents recursively * @recursive : list directory contents recursively
* *
@ -77,7 +79,8 @@ void dir_list_free(struct string_list *list);
* *
* Returns: -1 on error, 0 on success. * Returns: -1 on error, 0 on success.
**/ **/
int dir_list_read(const char *dir, struct string_list *list, struct string_list *ext_list, bool include_dirs, bool include_compressed, bool recursive); int dir_list_read(const char *dir, struct string_list *list, struct string_list *ext_list,
bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
RETRO_END_DECLS RETRO_END_DECLS

View File

@ -151,6 +151,7 @@ static int parse_dir_entry(const char *name, char *file_path,
* @dir : directory path. * @dir : directory path.
* @ext : allowed extensions of file directory entries to include. * @ext : allowed extensions of file directory entries to include.
* @include_dirs : include directories as part of the finished directory listing? * @include_dirs : include directories as part of the finished directory listing?
* @include_hidden : include hidden files and directories as part of the finished directory listing?
* @include_compressed : Only include files which match ext. Do not try to match compressed files, etc. * @include_compressed : Only include files which match ext. Do not try to match compressed files, etc.
* @recursive : list directory contents recursively * @recursive : list directory contents recursively
* *
@ -160,7 +161,7 @@ static int parse_dir_entry(const char *name, char *file_path,
* NULL in case of error. Has to be freed manually. * NULL in case of error. Has to be freed manually.
**/ **/
struct string_list *dir_list_new(const char *dir, struct string_list *dir_list_new(const char *dir,
const char *ext, bool include_dirs, bool include_compressed, bool recursive) const char *ext, bool include_dirs, bool include_hidden, bool include_compressed, bool recursive)
{ {
struct string_list *ext_list = NULL; struct string_list *ext_list = NULL;
struct string_list *list = NULL; struct string_list *list = NULL;
@ -171,7 +172,7 @@ struct string_list *dir_list_new(const char *dir,
if (ext) if (ext)
ext_list = string_split(ext, "|"); ext_list = string_split(ext, "|");
if(dir_list_read(dir, list, ext_list, include_dirs, include_compressed, recursive) == -1) { if(dir_list_read(dir, list, ext_list, include_dirs, include_hidden, include_compressed, recursive) == -1) {
string_list_free(list); string_list_free(list);
string_list_free(ext_list); string_list_free(ext_list);
return NULL; return NULL;
@ -187,6 +188,7 @@ struct string_list *dir_list_new(const char *dir,
* @list : the string list to add files to * @list : the string list to add files to
* @ext_list : the string list of extensions to include * @ext_list : the string list of extensions to include
* @include_dirs : include directories as part of the finished directory listing? * @include_dirs : include directories as part of the finished directory listing?
* @include_hidden : include hidden files and directories as part of the finished directory listing?
* @include_compressed : Only include files which match ext. Do not try to match compressed files, etc. * @include_compressed : Only include files which match ext. Do not try to match compressed files, etc.
* @recursive : list directory contents recursively * @recursive : list directory contents recursively
* *
@ -194,7 +196,7 @@ struct string_list *dir_list_new(const char *dir,
* *
* Returns: -1 on error, 0 on success. * Returns: -1 on error, 0 on success.
**/ **/
int dir_list_read(const char *dir, struct string_list *list, struct string_list *ext_list, bool include_dirs, bool include_compressed, bool recursive) int dir_list_read(const char *dir, struct string_list *list, struct string_list *ext_list, bool include_dirs, bool include_hidden, bool include_compressed, bool recursive)
{ {
struct RDIR *entry = retro_opendir(dir); struct RDIR *entry = retro_opendir(dir);
@ -207,6 +209,13 @@ int dir_list_read(const char *dir, struct string_list *list, struct string_list
return -1; return -1;
} }
#ifdef _WIN32
if (include_hidden)
entry.dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
else
entry.dwFileAttributes &= ~FILE_ATTRIBUTE_HIDDEN;
#endif
while (retro_readdir(entry)) while (retro_readdir(entry))
{ {
bool is_dir = false; bool is_dir = false;
@ -218,11 +227,17 @@ int dir_list_read(const char *dir, struct string_list *list, struct string_list
fill_pathname_join(file_path, dir, name, sizeof(file_path)); fill_pathname_join(file_path, dir, name, sizeof(file_path));
is_dir = retro_dirent_is_dir(entry, file_path); is_dir = retro_dirent_is_dir(entry, file_path);
if (!include_hidden)
{
if (*name == '.')
continue;
}
if(is_dir && recursive) { if(is_dir && recursive) {
if(strncmp(name, ".", 1) == 0 || strncmp(name, "..", 2) == 0) if(strstr(name, ".") || strstr(name, ".."))
continue; continue;
dir_list_read(file_path, list, ext_list, include_dirs, include_compressed, recursive); dir_list_read(file_path, list, ext_list, include_dirs, include_hidden, include_compressed, recursive);
} }
ret = parse_dir_entry(name, file_path, is_dir, ret = parse_dir_entry(name, file_path, is_dir,

View File

@ -44,6 +44,7 @@
#include "audio/audio_driver.h" #include "audio/audio_driver.h"
#include "audio/audio_resampler_driver.h" #include "audio/audio_resampler_driver.h"
#include "record/record_driver.h" #include "record/record_driver.h"
#include "configuration.h"
struct string_list *dir_list_new_special(const char *input_dir, struct string_list *dir_list_new_special(const char *input_dir,
enum dir_list_type type, const char *filter) enum dir_list_type type, const char *filter)
@ -54,6 +55,7 @@ struct string_list *dir_list_new_special(const char *input_dir,
const char *exts = NULL; const char *exts = NULL;
bool include_dirs = false; bool include_dirs = false;
bool recursive = false; bool recursive = false;
settings_t *settings = config_get_ptr();
(void)input_dir; (void)input_dir;
@ -135,7 +137,7 @@ struct string_list *dir_list_new_special(const char *input_dir,
return NULL; return NULL;
} }
return dir_list_new(dir, exts, include_dirs, type == DIR_LIST_CORE_INFO, recursive); return dir_list_new(dir, exts, include_dirs, settings->show_hidden_files, type == DIR_LIST_CORE_INFO, recursive);
} }
struct string_list *string_list_new_special(enum string_list_type type, struct string_list *string_list_new_special(enum string_list_type type,

View File

@ -3165,6 +3165,7 @@ static int menu_displaylist_parse_playlists(
size_t i, list_size; size_t i, list_size;
struct string_list *str_list = NULL; struct string_list *str_list = NULL;
unsigned items_found = 0; unsigned items_found = 0;
settings_t *settings = config_get_ptr();
if (!*info->path) if (!*info->path)
{ {
@ -3174,7 +3175,7 @@ static int menu_displaylist_parse_playlists(
return 0; return 0;
} }
str_list = dir_list_new(info->path, NULL, true, true, false); str_list = dir_list_new(info->path, NULL, true, settings->show_hidden_files, true, false);
if (!str_list) if (!str_list)
{ {
@ -3272,6 +3273,7 @@ static int menu_displaylist_parse_cores(
bool filter_ext = true; bool filter_ext = true;
struct string_list *str_list = NULL; struct string_list *str_list = NULL;
unsigned items_found = 0; unsigned items_found = 0;
settings_t *settings = config_get_ptr();
if (!*info->path) if (!*info->path)
{ {
@ -3283,7 +3285,7 @@ static int menu_displaylist_parse_cores(
str_list = dir_list_new(info->path, str_list = dir_list_new(info->path,
filter_ext ? info->exts : NULL, filter_ext ? info->exts : NULL,
true, true, false); true, settings->show_hidden_files, true, false);
{ {
char out_dir[PATH_MAX_LENGTH] = {0}; char out_dir[PATH_MAX_LENGTH] = {0};
@ -3489,7 +3491,7 @@ static int menu_displaylist_parse_generic(
else else
str_list = dir_list_new(info->path, str_list = dir_list_new(info->path,
filter_ext ? info->exts : NULL, filter_ext ? info->exts : NULL,
true, true, false); true, settings->show_hidden_files, true, false);
#ifdef HAVE_LIBRETRODB #ifdef HAVE_LIBRETRODB
if (BIT32_GET(filebrowser_types, FILEBROWSER_SCAN_DIR)) if (BIT32_GET(filebrowser_types, FILEBROWSER_SCAN_DIR))
@ -4474,6 +4476,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
menu_displaylist_parse_settings_enum(menu, info, menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE, MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE,
PARSE_ONLY_BOOL, false); PARSE_ONLY_BOOL, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_SHOW_HIDDEN_FILES,
PARSE_ONLY_BOOL, false);
info->need_refresh = true; info->need_refresh = true;
info->need_push = true; info->need_push = true;

View File

@ -4711,6 +4711,22 @@ static bool setting_append_list(
SD_FLAG_NONE); SD_FLAG_NONE);
menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT); menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT);
CONFIG_BOOL(
list, list_info,
&settings->show_hidden_files,
msg_hash_to_str(MENU_ENUM_LABEL_SHOW_HIDDEN_FILES),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHOW_HIDDEN_FILES),
show_hidden_files,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON),
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE);
menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_SHOW_HIDDEN_FILES);
CONFIG_BOOL( CONFIG_BOOL(
list, list_info, list, list_info,
&settings->game_specific_options, &settings->game_specific_options,

View File

@ -1147,6 +1147,9 @@ enum msg_hash_enums
MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT, MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT,
MENU_ENUM_LABEL_VALUE_CONFIG_SAVE_ON_EXIT, MENU_ENUM_LABEL_VALUE_CONFIG_SAVE_ON_EXIT,
MENU_ENUM_LABEL_SHOW_HIDDEN_FILES,
MENU_ENUM_LABEL_VALUE_SHOW_HIDDEN_FILES,
/* Driver settings */ /* Driver settings */
MENU_ENUM_LABEL_AUDIO_DRIVER, MENU_ENUM_LABEL_AUDIO_DRIVER,

View File

@ -122,6 +122,9 @@
# Load up a specific config file based on the core being used. # Load up a specific config file based on the core being used.
# core_specific_config = false # core_specific_config = false
# Shows hidden files and folders in directory listings.
# show_hidden_files = true
#### Video #### Video
# Video driver to use. "gl", "xvideo", "sdl" # Video driver to use. "gl", "xvideo", "sdl"