summaryrefslogtreecommitdiffstats
path: root/src/dirn.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2015-03-12 08:29:11 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2015-03-12 08:29:11 +0100
commitb7eba19a90be29ac810b1ed1283b223f44757f31 (patch)
treebdbd391f9c9c9a7ede97dff33962a845547650f4 /src/dirn.c
parentca0f2852732c188fc76b2a2cb149295342e6216d (diff)
File listing: use '/', 'n' and 'N' to search for a user specified name
Diffstat (limited to 'src/dirn.c')
-rw-r--r--src/dirn.c86
1 files changed, 67 insertions, 19 deletions
diff --git a/src/dirn.c b/src/dirn.c
index ce9a0ef..768fd10 100644
--- a/src/dirn.c
+++ b/src/dirn.c
@@ -101,6 +101,7 @@ static long int dir_aff_ncurses(disk_t *disk, const partition_t *partition, dir_
int quit=0;
int ask_destination=1;
WINDOW *window=(WINDOW*)dir_data->display;
+ const char *needle=NULL;
do
{
int offset=0;
@@ -492,34 +493,81 @@ static long int dir_aff_ncurses(disk_t *disk, const partition_t *partition, dir_
copy_done(window, copy_ok, copy_bad);
}
}
- break;
+ break;
+ case '/':
case 'f':
+ needle=ask_string_ncurses("Filename to find ? ");
+ if(needle!=NULL && needle[0]!='\0' && pos->next!=&dir_list->list)
{
- const char *needle=ask_string_ncurses("Filename to find ? ");
- if(needle!=NULL && needle[0]!='\0')
+ const file_info_t *tmp;
+ struct td_list_head *pos_org=pos;
+ const int pos_num_org=pos_num;
+ tmp=td_list_entry(pos, file_info_t, list);
+ while(pos->next!=&dir_list->list &&
+ strcasestr(tmp->name, needle)==NULL)
{
- file_info_t *tmp;
- struct td_list_head *pos_org=pos;
- const int pos_num_org=pos_num;
+ pos=pos->next;
tmp=td_list_entry(pos, file_info_t, list);
- while(pos->next!=&dir_list->list &&
- strcmp(tmp->name, needle)!=0)
- {
- pos=pos->next;
- tmp=td_list_entry(pos, file_info_t, list);
- pos_num++;
- }
- if(pos==&dir_list->list)
- {
- pos=pos_org;
- pos_num=pos_num_org;
- }
+ pos_num++;
+ }
+ if(strcasestr(tmp->name, needle)==NULL)
+ {
+ pos=pos_org;
+ pos_num=pos_num_org;
+ }
+ }
+ break;
+ case 'n':
+ if(needle!=NULL && needle[0]!='\0' && pos->next!=&dir_list->list)
+ {
+ const file_info_t *tmp;
+ struct td_list_head *pos_org=pos;
+ const int pos_num_org=pos_num;
+ tmp=td_list_entry(pos, file_info_t, list);
+ pos=pos->next;
+ tmp=td_list_entry(pos, file_info_t, list);
+ pos_num++;
+ while(pos->next!=&dir_list->list &&
+ strcasestr(tmp->name, needle)==0)
+ {
+ pos=pos->next;
+ tmp=td_list_entry(pos, file_info_t, list);
+ pos_num++;
+ }
+ if(strcasestr(tmp->name, needle)==0)
+ {
+ pos=pos_org;
+ pos_num=pos_num_org;
+ }
+ }
+ break;
+ case 'N':
+ if(needle!=NULL && needle[0]!='\0' && pos->prev!=&dir_list->list)
+ {
+ const file_info_t *tmp;
+ struct td_list_head *pos_org=pos;
+ const int pos_num_org=pos_num;
+ tmp=td_list_entry(pos, file_info_t, list);
+ pos=pos->prev;
+ tmp=td_list_entry(pos, file_info_t, list);
+ pos_num--;
+ while(pos->prev!=&dir_list->list &&
+ strcasestr(tmp->name, needle)==0)
+ {
+ pos=pos->prev;
+ tmp=td_list_entry(pos, file_info_t, list);
+ pos_num--;
+ }
+ if(strcasestr(tmp->name, needle)==0)
+ {
+ pos=pos_org;
+ pos_num=pos_num_org;
}
}
break;
case 'F':
{
- const char *needle=ask_string_ncurses("Filter ? ");
+ needle=ask_string_ncurses("Filter ? ");
if(needle!=NULL && needle[0]!='\0')
{
struct td_list_head *tmpw= NULL;