diff -x plugins -x codecs -x CVS -x build-simulator -x build-firmware -x build-profile -x build-clean -x build-bootloader --exclude='*.patch' --exclude='*.diff' --exclude='*.profile' --exclude='*.tar*' --exclude='*.out' --exclude='.*' -ru rockbox-profile/apps/filetree.c rockbox/apps/filetree.c --- rockbox-profile/apps/filetree.c 2005-12-08 19:36:28.000000000 -0600 +++ rockbox/apps/filetree.c 2006-01-07 09:26:31.000000000 -0600 @@ -131,6 +131,17 @@ closedir_cached(dir); } +static inline long get_leading_number(char *name) { + int retval = 0; + int i; + int l = strlen(name); + for (i=0; i < l && name[i] <= '9' && name[i] >= '0'; i++) { + retval *= 10; + retval += name[i] - '0'; + } + return retval; +} + /* support function for qsort() */ static int compare(const void* p1, const void* p2) { @@ -159,6 +170,23 @@ switch(criteria) { + case 0: /* sort alphabetically asc */ +alpha: + if (global_settings.sort_case) + return strncmp(e1->name, e2->name, MAX_PATH); + else + return strncasecmp(e1->name, e2->name, MAX_PATH); + + case 1: /* sort date */ + if (e1->time_write - e2->time_write) + return e1->time_write - e2->time_write; + goto alpha; + + case 2: /* sort date, newest first */ + if (e2->time_write - e1->time_write) + return e2->time_write - e1->time_write; + goto alpha; + case 3: /* sort type */ { int t1 = e1->attr & TREE_ATTR_MASK; @@ -172,24 +200,23 @@ if (t1 - t2) /* if different */ return t1 - t2; /* else fall through to alphabetical sorting */ + goto alpha; } - case 0: /* sort alphabetically asc */ - if (global_settings.sort_case) - return strncmp(e1->name, e2->name, MAX_PATH); - else - return strncasecmp(e1->name, e2->name, MAX_PATH); - case 4: /* sort alphabetically desc */ + case 4: /* sort numerically asc */ + { + long n1 = get_leading_number(e1->name); + long n2 = get_leading_number(e2->name); + if (n1 - n2) + return n1 - n2; + goto alpha; + } + + case 5: /* sort alphabetically desc */ if (global_settings.sort_case) return strncmp(e2->name, e1->name, MAX_PATH); else return strncasecmp(e2->name, e1->name, MAX_PATH); - - case 1: /* sort date */ - return e1->time_write - e2->time_write; - - case 2: /* sort date, newest first */ - return e2->time_write - e1->time_write; } return 0; /* never reached */ } diff -x plugins -x codecs -x CVS -x build-simulator -x build-firmware -x build-profile -x build-clean -x build-bootloader --exclude='*.patch' --exclude='*.diff' --exclude='*.profile' --exclude='*.tar*' --exclude='*.out' --exclude='.*' -ru rockbox-profile/apps/lang/english.lang rockbox/apps/lang/english.lang --- rockbox-profile/apps/lang/english.lang 2005-12-22 15:39:14.000000000 -0600 +++ rockbox/apps/lang/english.lang 2006-01-07 09:13:06.000000000 -0600 @@ -2704,6 +2704,12 @@ voice: "Alphabetical" new: +id: LANG_SORT_NUM +desc browser sorting setting +eng: "Numeric" +voice: "Numeric" +new: + id: LANG_SORT_DATE desc: browser sorting setting eng: "by date" diff -x plugins -x codecs -x CVS -x build-simulator -x build-firmware -x build-profile -x build-clean -x build-bootloader --exclude='*.patch' --exclude='*.diff' --exclude='*.profile' --exclude='*.tar*' --exclude='*.out' --exclude='.*' -ru rockbox-profile/apps/settings.c rockbox/apps/settings.c --- rockbox-profile/apps/settings.c 2005-12-22 15:39:14.000000000 -0600 +++ rockbox/apps/settings.c 2006-01-07 09:38:16.000000000 -0600 @@ -85,7 +85,7 @@ #include "dsp.h" #endif -#define CONFIG_BLOCK_VERSION 36 +#define CONFIG_BLOCK_VERSION 37 #define CONFIG_BLOCK_SIZE 512 #define RTC_BLOCK_SIZE 44 @@ -412,7 +412,7 @@ {2, S_O(talk_file), 0, "talk file", off_number_spell_hover }, {1, S_O(talk_menu), true, "talk menu", off_on }, - {2, S_O(sort_file), 0, "sort files", "alpha,oldest,newest,type" }, + {3, S_O(sort_file), 0, "sort files", "alpha,oldest,newest,type,number" }, {2, S_O(sort_dir), 0, "sort dirs", "alpha,oldest,newest" }, {1, S_O(id3_v1_first), 0, "id3 tag priority", "v2-v1,v1-v2"}, diff -x plugins -x codecs -x CVS -x build-simulator -x build-firmware -x build-profile -x build-clean -x build-bootloader --exclude='*.patch' --exclude='*.diff' --exclude='*.profile' --exclude='*.tar*' --exclude='*.out' --exclude='.*' -ru rockbox-profile/apps/settings.h rockbox/apps/settings.h --- rockbox-profile/apps/settings.h 2005-12-22 22:17:41.000000000 -0600 +++ rockbox/apps/settings.h 2006-01-07 09:09:18.000000000 -0600 @@ -346,7 +346,7 @@ int talk_file; /* voice filename mode: 0=off, 1=number, other t.b.d. */ /* file browser sorting */ - int sort_file; /* 0=alpha, 1=date, 2=date (new first), 3=type */ + int sort_file; /* 0=alpha, 1=date, 2=date (new first), 3=type, 4=number */ int sort_dir; /* 0=alpha, 1=date (old first), 2=date (new first) */ #ifdef HAVE_REMOTE_LCD diff -x plugins -x codecs -x CVS -x build-simulator -x build-firmware -x build-profile -x build-clean -x build-bootloader --exclude='*.patch' --exclude='*.diff' --exclude='*.profile' --exclude='*.tar*' --exclude='*.out' --exclude='.*' -ru rockbox-profile/apps/settings_menu.c rockbox/apps/settings_menu.c --- rockbox-profile/apps/settings_menu.c 2005-12-22 15:39:14.000000000 -0600 +++ rockbox/apps/settings_menu.c 2006-01-07 09:11:59.000000000 -0600 @@ -627,10 +627,11 @@ { STR(LANG_SORT_ALPHA) }, { STR(LANG_SORT_DATE) }, { STR(LANG_SORT_DATE_REVERSE) }, - { STR(LANG_SORT_TYPE) } + { STR(LANG_SORT_TYPE) }, + { STR(LANG_SORT_NUM) } }; ret = set_option( str(LANG_SORT_FILE), &global_settings.sort_file, INT, - names, 4, NULL ); + names, 5, NULL ); if (global_settings.sort_file != oldval) reload_directory(); /* force reload if this has changed */ return ret;