Skip to content

Commit

Permalink
Skip trash directory by default. (#2831)
Browse files Browse the repository at this point in the history
  • Loading branch information
ventoy committed May 19, 2024
1 parent c16e761 commit 1b2483e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
9 changes: 9 additions & 0 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
16 changes: 14 additions & 2 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 1b2483e

Please sign in to comment.