src/find.c: 'Skip .hidden files and dirs' has been introduced.

An option to toggle on|off searching for|in hidden directories
and files. (#132)

Signed-off-by: Mikhail S. Pobolovets <styx.mp@gmail.com>
This commit is contained in:
Mikhail S. Pobolovets 2009-02-21 11:53:38 +02:00
parent c7987f0b1d
commit dbba22eae3
2 changed files with 40 additions and 24 deletions

View File

@ -1,3 +1,9 @@
2009-02-20 Mikhail Pobolovets <styx.mp@gmail.com>
* src/find.c: 'Skip .hidden files and dirs' has been introduced.
An option to toggle on|off searching for|in hidden directories
and files. (#132)
2009-02-19 Andrew Borodin <aborodin@vmail.ru> 2009-02-19 Andrew Borodin <aborodin@vmail.ru>
* src/screen.c: reimplemented displaying size of total marked files. * src/screen.c: reimplemented displaying size of total marked files.
If mini-status is on, total size is displayed on mini_info_separator. If mini-status is on, total size is displayed on mini_info_separator.

View File

@ -47,7 +47,7 @@
#include "key.h" #include "key.h"
/* Size of the find parameters window */ /* Size of the find parameters window */
#define FIND_Y 15 #define FIND_Y 16
static int FIND_X = 50; static int FIND_X = 50;
/* Size of the find window */ /* Size of the find window */
@ -142,6 +142,7 @@ static regex_t *r; /* Pointer to compiled content_pattern */
static int case_sensitive = 1; static int case_sensitive = 1;
static gboolean find_regex_flag = TRUE; static gboolean find_regex_flag = TRUE;
static gboolean skip_hidden_flag = FALSE;
static int find_recursively = 1; static int find_recursively = 1;
/* /*
@ -196,8 +197,10 @@ find_parameters (char **start_dir, char **pattern, char **content)
char *temp_dir; char *temp_dir;
static const char *case_label = N_("case &Sensitive"); static const char *case_label = N_("case &Sensitive");
static const char *recurs_label = N_("&Find recursively"); static const char *recurs_label = N_("&Find recursively");
static const char *skip_hidden_label = N_("Ski&p .hidden files and dirs");
WCheck *recursively_cbox; WCheck *recursively_cbox;
WCheck *skip_hidden_cbox;
static char *in_contents = NULL; static char *in_contents = NULL;
static char *in_start_dir = NULL; static char *in_start_dir = NULL;
@ -258,15 +261,18 @@ find_parameters (char **start_dir, char **pattern, char **content)
DLG_CENTER | DLG_REVERSE); DLG_CENTER | DLG_REVERSE);
add_widget (find_dlg, add_widget (find_dlg,
button_new (12, b2, B_CANCEL, NORMAL_BUTTON, buts[2], 0)); button_new (FIND_Y - 3, b2, B_CANCEL, NORMAL_BUTTON, buts[2], 0));
add_widget (find_dlg, add_widget (find_dlg,
button_new (12, b1, B_TREE, NORMAL_BUTTON, buts[1], 0)); button_new (FIND_Y - 3, b1, B_TREE, NORMAL_BUTTON, buts[1], 0));
add_widget (find_dlg, add_widget (find_dlg,
button_new (12, b0, B_ENTER, DEFPUSH_BUTTON, buts[0], 0)); button_new (FIND_Y - 3, b0, B_ENTER, DEFPUSH_BUTTON, buts[0], 0));
recursively_cbox = recursively_cbox =
check_new (6, istart, find_recursively, recurs_label); check_new (6, istart, find_recursively, recurs_label);
skip_hidden_cbox = check_new (11, istart, skip_hidden_flag, skip_hidden_label);
add_widget (find_dlg, skip_hidden_cbox);
find_regex_cbox = check_new (10, istart, find_regex_flag, _("&Regular expression")); find_regex_cbox = check_new (10, istart, find_regex_flag, _("&Regular expression"));
add_widget (find_dlg, find_regex_cbox); add_widget (find_dlg, find_regex_cbox);
@ -304,6 +310,7 @@ find_parameters (char **start_dir, char **pattern, char **content)
case_sensitive = case_sense->state & C_BOOL; case_sensitive = case_sense->state & C_BOOL;
find_regex_flag = find_regex_cbox->state & C_BOOL; find_regex_flag = find_regex_cbox->state & C_BOOL;
find_recursively = recursively_cbox->state & C_BOOL; find_recursively = recursively_cbox->state & C_BOOL;
skip_hidden_flag = skip_hidden_cbox->state & C_BOOL;
destroy_dlg (find_dlg); destroy_dlg (find_dlg);
g_free (in_start_dir); g_free (in_start_dir);
if (strcmp (temp_dir, ".") == 0) { if (strcmp (temp_dir, ".") == 0) {
@ -332,6 +339,7 @@ find_parameters (char **start_dir, char **pattern, char **content)
case_sensitive = case_sense->state & C_BOOL; case_sensitive = case_sense->state & C_BOOL;
find_regex_flag = find_regex_cbox->state & C_BOOL; find_regex_flag = find_regex_cbox->state & C_BOOL;
find_recursively = recursively_cbox->state & C_BOOL; find_recursively = recursively_cbox->state & C_BOOL;
skip_hidden_flag = skip_hidden_cbox->state & C_BOOL;
return_value = 1; return_value = 1;
*start_dir = g_strdup (in_start->buffer); *start_dir = g_strdup (in_start->buffer);
*pattern = g_strdup (in_name->buffer); *pattern = g_strdup (in_name->buffer);
@ -690,6 +698,7 @@ do_search (struct Dlg_head *h)
return 1; return 1;
} }
if (!(skip_hidden_flag && dp->d_name[0] == '.')) {
if (subdirs_left && find_recursively && directory) { /* Can directory be NULL ? */ if (subdirs_left && find_recursively && directory) { /* Can directory be NULL ? */
char *tmp_name = concat_dir_and_file (directory, dp->d_name); char *tmp_name = concat_dir_and_file (directory, dp->d_name);
if (!mc_lstat (tmp_name, &tmp_stat) if (!mc_lstat (tmp_name, &tmp_stat)
@ -708,6 +717,7 @@ do_search (struct Dlg_head *h)
} else } else
find_add_match (h, directory, dp->d_name); find_add_match (h, directory, dp->d_name);
} }
}
dp = mc_readdir (dirp); dp = mc_readdir (dirp);