vlc | branch: master | Antoine Cellerier <[email protected]> | Wed Feb 8 00:25:14 2012 +0100| [3821b962f3fe65bafe8d6600fca594f12ce01ebc] | committer: Antoine Cellerier
Revert "Remove version sort option. Now uses version sort by default and there's no way to change it :)" This reverts commit 285098dc1e0bfa25877842a4a9f7ee04cdd39424. I haven't been able to find an acceptable solution to the problem other than writing our own strverscoll which doesn't seem easy at all. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3821b962f3fe65bafe8d6600fca594f12ce01ebc --- modules/access/directory.c | 19 +++++++++++++++++-- modules/access/fs.c | 9 +++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/access/directory.c b/modules/access/directory.c index fbd27d1..9bffe05 100644 --- a/modules/access/directory.c +++ b/modules/access/directory.c @@ -79,6 +79,7 @@ struct access_sys_t bool header; int i_item_count; char *xspf_ext; + int (*compar)(const char **a, const char **b); }; /* Select non-hidden files only */ @@ -87,6 +88,15 @@ static int visible (const char *name) return name[0] != '.'; } +static int collate (const char **a, const char **b) +{ +#ifdef HAVE_STRCOLL + return strcoll (*a, *b); +#else + return strcmp (*a, *b); +#endif +} + static int version (const char **a, const char **b) { return strverscmp (*a, *b); @@ -134,10 +144,15 @@ int DirInit (access_t *p_access, DIR *handle) goto error; } + if (var_InheritBool (p_access, "directory-version-sort")) + p_sys->compar = version; + else + p_sys->compar = collate; + root->parent = NULL; root->handle = handle; root->uri = uri; - root->filec = vlc_loaddir (handle, &root->filev, visible, version); + root->filec = vlc_loaddir (handle, &root->filev, visible, p_sys->compar); if (root->filec < 0) root->filev = NULL; root->i = 0; @@ -345,7 +360,7 @@ block_t *DirBlock (access_t *p_access) } sub->parent = current; sub->handle = handle; - sub->filec = vlc_loaddir (handle, &sub->filev, visible, version); + sub->filec = vlc_loaddir (handle, &sub->filev, visible, p_sys->compar); if (sub->filec < 0) sub->filev = NULL; sub->i = 0; diff --git a/modules/access/fs.c b/modules/access/fs.c index 5fb16dc..9913b22 100644 --- a/modules/access/fs.c +++ b/modules/access/fs.c @@ -48,6 +48,13 @@ static const char *const psz_recursive_list_text[] = { "This is useful if you add directories that contain playlist files " \ "for instance. Use a comma-separated list of extensions." ) +#define VERSION_SORT_TEXT N_("Use version sort") +#define VERSION_SORT_LONGTEXT N_( \ + "When opening a directory, add items in a natural order. " \ + "For example, track-1.ogg track-2.ogg track-10.ogg will be sorted " \ + "as expected while the default method would sort them as " \ + "track-1.ogg track-10.ogg track-2.ogg." ) + vlc_module_begin () set_description( N_("File input") ) set_shortname( N_("File") ) @@ -66,6 +73,8 @@ vlc_module_begin () change_string_list( psz_recursive_list, psz_recursive_list_text, 0 ) add_string( "ignore-filetypes", "m3u,db,nfo,ini,jpg,jpeg,ljpg,gif,png,pgm,pgmyuv,pbm,pam,tga,bmp,pnm,xpm,xcf,pcx,tif,tiff,lbm,sfv,txt,sub,idx,srt,cue,ssa", IGNORE_TEXT, IGNORE_LONGTEXT, false ) + add_bool( "directory-version-sort", false, + VERSION_SORT_TEXT, VERSION_SORT_LONGTEXT, false ); #ifndef HAVE_FDOPENDIR add_shortcut( "file", "directory", "dir" ) #else _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
