Hello All!
Patch for Exe files sort.
Idea from Dos Navigator.
All x files on top after directories.
diff -urN mc-4.6.0.orig/pc/drive.c mc-4.6.0/pc/drive.c
--- mc-4.6.0.orig/pc/drive.c Mon Oct 21 06:13:52 2002
+++ mc-4.6.0/pc/drive.c Mon Feb 10 14:31:47 2003
@@ -151,6 +151,7 @@
this_panel-sort_type,
this_panel-reverse,
this_panel-case_sensitive,
+this_panel-exe_first,
this_panel-filter);
this_panel-top_file = 0;
this_panel-selected = 0;
diff -urN mc-4.6.0.orig/src/boxes.c mc-4.6.0/src/boxes.c
--- mc-4.6.0.orig/src/boxes.c Sun Dec 8 05:16:30 2002
+++ mc-4.6.0/src/boxes.c Mon Feb 10 14:32:54 2003
@@ -266,17 +266,18 @@
static char *sort_orders_names [SORT_TYPES];
sortfn *
-sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive)
+sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive, int *exe_first)
{
int i, r, l;
sortfn *result;
-WCheck *c, *case_sense;
+WCheck *c, *case_sense, *exe_sense;
char* ok_button = _(OK);
char* cancel_button = _(Cancel);
char* reverse_label = _(Reverse);
char* case_label = _(case sensitive);
char* sort_title = _(Sort order);
+ char* exe_label = _(exe first);
static int i18n_sort_flag = 0, check_pos = 0, button_pos = 0;
@@ -336,6 +337,8 @@
button_new (9, button_pos, B_ENTER, DEFPUSH_BUTTON, ok_button,
0, 0, ok-button));
+exe_sense = check_new (5, check_pos, *exe_first, exe_label, exe-check);
+add_widget (dd, exe_sense);
case_sense = check_new (4, check_pos, *case_sensitive, case_label, case-check);
add_widget (dd, case_sense);
c = check_new (3, check_pos, *reverse, reverse_label, reverse-check);
@@ -352,6 +355,7 @@
result = (sortfn *) sort_orders [my_radio-sel].sort_fn;
*reverse = c-state C_BOOL;
*case_sensitive = case_sense-state C_BOOL;
+ *exe_first = exe_sense-state C_BOOL;
} else
result = sort_fn;
destroy_dlg (dd);
diff -urN mc-4.6.0.orig/src/boxes.h mc-4.6.0/src/boxes.h
--- mc-4.6.0.orig/src/boxes.h Mon Aug 19 03:01:20 2002
+++ mc-4.6.0/src/boxes.h Mon Feb 10 14:31:31 2003
@@ -4,7 +4,7 @@
int display_box (WPanel *p, char **user, char **mini,
int *use_msformat, int num);
sortfn *sort_box (sortfn *sort_fn, int *reverse,
- int *case_sensitive);
+ int *case_sensitive, int *exe_first);
voidconfirm_box (void);
voiddisplay_bits_box (void);
voidconfigure_vfs(void);
diff -urN mc-4.6.0.orig/src/dir.c mc-4.6.0/src/dir.c
--- mc-4.6.0.orig/src/dir.c Tue Jan 21 01:41:45 2003
+++ mc-4.6.0/src/dir.c Mon Feb 10 14:37:44 2003
@@ -44,7 +44,12 @@
/* Are the files sorted case sensitively? */
static int case_sensitive = OS_SORT_CASE_SENSITIVE_DEFAULT;
+/* Are the files sorted with exe first? */
+static int exe_first = OS_SORT_EXE_FIRST_DEFAULT;
+
#define MY_ISDIR(x) ( (S_ISDIR (x-buf.st_mode) || x-f.link_to_dir) ? 1 : 0)
+// Alexander Riedel
+#define MY_ISEXEC(x) ( ((x-buf.st_mode 00100 || x-buf.st_mode 00010 || x-buf.st_mode 1) ) ? 1 : 0)
sort_orders_t sort_orders [SORT_TYPES_TOTAL] = {
{ N_(Unsorted),unsorted },
@@ -119,6 +124,11 @@
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
+if (exe_first !(ad || bd)){
+ ad = MY_ISEXEC (a);
+ bd = MY_ISEXEC (b);
+}
+
if (ad == bd || mix_all_files)
return string_sortcomp (a-fname, b-fname) * reverse;
return bd-ad;
@@ -132,6 +142,11 @@
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
+if (exe_first !(ad || bd)){
+ ad = MY_ISEXEC (a);
+ bd = MY_ISEXEC (b);
+}
+
if (ad == bd || mix_all_files){
exta = extension (a-fname);
extb = extension (b-fname);
@@ -150,6 +165,11 @@
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
+if (exe_first !(ad || bd)){
+ ad = MY_ISEXEC (a);
+ bd = MY_ISEXEC (b);
+}
+
if (ad == bd || mix_all_files)
return string_sortcomp (get_owner (a-buf.st_uid), get_owner (a-buf.st_uid)) * reverse;
return bd-ad;
@@ -161,6 +181,11 @@
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
+if (exe_first !(ad || bd)){
+ ad = MY_ISEXEC (a);
+ bd = MY_ISEXEC (b);
+}
+
if (ad == bd || mix_all_files)
return string_sortcomp (get_group (a-buf.st_gid), get_group (a-buf.st_gid)) * reverse;
return bd-ad;
@@ -172,6 +197,11 @@
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
+if (exe_first !(ad || bd)){
+ ad = MY_ISEXEC (a);
+ bd = MY_ISEXEC (b);
+}
+
if (ad == bd || mix_all_files)
return (a-buf.st_mtime - b-buf.st_mtime) * reverse;
else
@@ -184,6 +214,11 @@
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
+if (exe_first !(ad || bd)){
+ ad = MY_ISEXEC (a);
+ bd = MY_ISEXEC (b);
+}
+
if (ad == bd || mix_all_files)
return (a-buf.st_ctime - b-buf.st_ctime) * reverse;
else
@@ -196,6 +231,11 @@
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
+if (exe_first !(ad || bd)){
+ ad = MY_ISEXEC (a);
+ bd = MY_ISEXEC (b);
+}
+
if (ad == bd ||