summaryrefslogtreecommitdiffstats
path: root/src/dir.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-05-01 18:01:46 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2008-05-01 18:01:46 +0200
commit7dfe3287092af860d5f3db74e9b8d37a75f5b71c (patch)
treeda8847033e89366746304d645df32b99f89b6621 /src/dir.c
parent9d87952b714a304502e39edc5a7ce12e5ef01abd (diff)
When listing local directories, directories first, files next, both sorted by name (. and .. always first)
Allow navigation using numerical keys Fix for DOS version
Diffstat (limited to 'src/dir.c')
-rw-r--r--src/dir.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/dir.c b/src/dir.c
index 88f34df..7cc8323 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -2,7 +2,7 @@
File: dir.c
- Copyright (C) 1998-2007 Christophe GRENIER <grenier@cgsecurity.org>
+ Copyright (C) 1998-2008 Christophe GRENIER <grenier@cgsecurity.org>
This software is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -346,6 +346,7 @@ static long int dir_aff_ncurses(disk_t *disk_car, const partition_t *partition,
break;
case '-':
case KEY_LEFT:
+ case '4':
if(depth>0)
return 1;
break;
@@ -358,6 +359,7 @@ static long int dir_aff_ncurses(disk_t *disk_car, const partition_t *partition,
switch(car)
{
case KEY_UP:
+ case '8':
if(pos->prev!=NULL)
{
pos=pos->prev;
@@ -367,6 +369,7 @@ static long int dir_aff_ncurses(disk_t *disk_car, const partition_t *partition,
offset--;
break;
case KEY_DOWN:
+ case '2':
if(pos->next!=NULL)
{
pos=pos->next;
@@ -382,7 +385,7 @@ static long int dir_aff_ncurses(disk_t *disk_car, const partition_t *partition,
case KEY_RIGHT:
case '\r':
case '\n':
-
+ case '6':
case KEY_ENTER:
#ifdef PADENTER
case PADENTER:
@@ -710,3 +713,21 @@ int set_date(const char *pathname, time_t actime, time_t modtime)
return 0;
#endif
}
+
+int filesort(const struct td_list_head *a, const struct td_list_head *b)
+{
+ const struct file_info *file_a=td_list_entry(a, struct file_info, list);
+ const struct file_info *file_b=td_list_entry(b, struct file_info, list);
+ /* Directories must be listed before files */
+ const int res=((file_b->stat.st_mode&LINUX_S_IFDIR)-(file_a->stat.st_mode&LINUX_S_IFDIR));
+ if(res)
+ return res;
+ /* . and .. must listed before the other directories */
+ if((file_a->stat.st_mode&LINUX_S_IFDIR) && strcmp(file_a->name,".")==0)
+ return -1;
+ if((file_a->stat.st_mode&LINUX_S_IFDIR) && strcmp(file_a->name,"..")==0 &&
+ !strcmp(file_b->name,".")==0)
+ return -1;
+ /* Files and directories are sorted by name */
+ return strcmp(file_a->name,file_b->name);
+}