Skip to content

Commit

Permalink
Filter the files jeg, opf, displayed in the file explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-emmabuntus committed Apr 16, 2024
1 parent e9a454b commit cacb9f0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/list_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,33 @@ void ls (misc_t *misc, size_t n, struct dirent **namelist)

int hidden_files (const struct dirent *entry)
{

int r = 0;
char my_pattern1[] = "*.jpg";
char my_pattern2[] = "*.opf";
char my_pattern3[] = "*.pdf";
char my_pattern4[] = "*.db";
char my_pattern5[] = "*.json";

if (*entry->d_name == '.')
return 0;

r = fnmatch (my_pattern1, entry->d_name, FNM_PERIOD | FNM_CASEFOLD);
if (r == 0)
return 0;
r = fnmatch (my_pattern2, entry->d_name, FNM_PERIOD | FNM_CASEFOLD);
if (r == 0)
return 0;
r = fnmatch (my_pattern3, entry->d_name, FNM_PERIOD | FNM_CASEFOLD);
if (r == 0)
return 0;
r = fnmatch (my_pattern4, entry->d_name, FNM_PERIOD | FNM_CASEFOLD);
if (r == 0)
return 0;
r = fnmatch (my_pattern5, entry->d_name, FNM_PERIOD | FNM_CASEFOLD);
if (r == 0)
return 0;

return 1;
} // hidden)files

Expand Down

1 comment on commit cacb9f0

@patrick-emmabuntus
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to filter only the files you want to see using an option in the command line

Please sign in to comment.