+ const vlc_subfn_t *p0 = a;
+ const vlc_subfn_t *p1 = b;
+
+ if( p0->priority > p1->priority )
+ return -1;
+
+ if( p0->priority < p1->priority )
+ return 1;
+
+#ifndef UNDER_CE
+ return strcoll( p0->psz_fname, p1->psz_fname);
+#else
+ return strcmp( p0->psz_fname, p1->psz_fname);
+#endif
+}
+
+/*
+ * Check if a file ends with a subtitle extension
+ */
+int subtitles_Filter( const char *psz_dir_content )
+{
+ const char *tmp = strrchr( psz_dir_content, '.');
+
+ if( !tmp )
+ return 0;
+ tmp++;
+
+ for( int i = 0; sub_exts[i][0]; i++ )
+ if( strcasecmp( sub_exts[i], tmp ) == 0 )
+ return 1;
+ return 0;
+}
+
+
+/**
+ * Convert a list of paths separated by ',' to a char**
+ */
+static char **paths_to_list( const char *psz_dir, char *psz_path )
+{
+ unsigned int i, k, i_nb_subdirs;
+ char **subdirs; /* list of subdirectories to look in */
+ char *psz_parser = psz_path;
+
+ if( !psz_dir || !psz_path )
+ return NULL;
+
+ for( k = 0, i_nb_subdirs = 1; psz_path[k] != '\0'; k++ )
+ {
+ if( psz_path[k] == ',' )
+ i_nb_subdirs++;
+ }
+
+ subdirs = calloc( i_nb_subdirs + 1, sizeof(char*) );
+ if( !subdirs )
+ return NULL;
+
+ for( i = 0; psz_parser && *psz_parser != '\0' ; )
+ {
+ char *psz_subdir = psz_parser;
+ psz_parser = strchr( psz_subdir, ',' );
+ if( psz_parser )
+ {
+ *psz_parser++ = '\0';
+ while( *psz_parser == ' ' )
+ psz_parser++;
+ }
+ if( *psz_subdir == '\0' )
+ continue;
+
+ if( asprintf( &subdirs[i++], "%s%s%c",
+ psz_subdir[0] == '.' ? psz_dir : "",
+ psz_subdir,
+ psz_subdir[strlen(psz_subdir) - 1] == DIR_SEP_CHAR ?
+ '\0' : DIR_SEP_CHAR ) == -1 )
+ break;