Skip trash directory by default. (#2831)

This commit is contained in:
longpanda 2024-05-19 16:00:46 +08:00
parent c16e76130b
commit 1b2483ec14
3 changed files with 24 additions and 2 deletions

View File

@ -244,6 +244,15 @@ static int ventoy_browser_valid_dirname(const char *name, int len)
return 0;
}
if (g_filt_trash_dir)
{
if (0 == grub_strncmp(name, ".trash-", 7) ||
0 == grub_strcmp(name, ".Trashes"))
{
return 0;
}
}
if (name[0] == '$')
{
if (0 == grub_strncmp(name, "$RECYCLE.BIN", 12) ||

View File

@ -65,6 +65,7 @@ int g_initrd_img_count = 0;
int g_valid_initrd_count = 0;
int g_default_menu_mode = 0;
int g_filt_dot_underscore_file = 0;
int g_filt_trash_dir = 1;
int g_sort_case_sensitive = 0;
int g_tree_view_menu_style = 0;
static grub_file_t g_old_file;
@ -1900,9 +1901,14 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
return 0;
}
if (filename[0] == '$' && 0 == grub_strncmp(filename, "$RECYCLE.BIN", 12))
if (g_filt_trash_dir)
{
return 0;
if (0 == grub_strncmp(filename, ".trash-", 7) ||
0 == grub_strcmp(filename, ".Trashes") ||
0 == grub_strncmp(filename, "$RECYCLE.BIN", 12))
{
return 0;
}
}
if (g_plugin_image_list == VENTOY_IMG_WHITE_LIST)
@ -2831,6 +2837,12 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
{
g_filt_dot_underscore_file = 1;
}
strdata = ventoy_get_env("VTOY_FILT_TRASH_DIR");
if (strdata && strdata[0] == '0' && strdata[1] == 0)
{
g_filt_trash_dir = 0;
}
strdata = ventoy_get_env("VTOY_SORT_CASE_SENSITIVE");
if (strdata && strdata[0] == '1' && strdata[1] == 0)

View File

@ -1298,6 +1298,7 @@ extern int g_tree_view_menu_style;
extern int g_sort_case_sensitive;
extern int g_wimboot_enable;
extern int g_filt_dot_underscore_file;
extern int g_filt_trash_dir;
extern int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT];
extern const char *g_menu_class[img_type_max];
extern char g_iso_path[256];