[vlc-devel] [PATCH 7/8] demux/directory: add show-hiddenfiles option

Thomas Guillem thomas at gllm.fr
Thu May 7 12:10:31 CEST 2015


False by default, i.e. we don't show hidden files by default.
---
 modules/demux/playlist/directory.c | 8 ++++++--
 src/libvlc-module.c                | 6 ++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/demux/playlist/directory.c b/modules/demux/playlist/directory.c
index b95746a..bb9dfb8 100644
--- a/modules/demux/playlist/directory.c
+++ b/modules/demux/playlist/directory.c
@@ -150,11 +150,13 @@ static int Demux( demux_t *p_demux )
     input_item_t *p_item;
     input_item_compar_cb compar_cb = NULL;
     char *psz_ignored_exts;
+    bool b_show_hiddenfiles;
 
     p_input = GetCurrentItem( p_demux );
     p_node = input_item_node_Create( p_input );
     input_item_Release(p_input);
 
+    b_show_hiddenfiles = var_InheritBool( p_demux, "show-hiddenfiles" );
     psz_ignored_exts = var_InheritString( p_demux, "ignore-filetypes" );
     if( !p_demux->p_sys->b_dir_sorted )
     {
@@ -175,8 +177,10 @@ static int Demux( demux_t *p_demux )
     {
         int i_name_len = p_item->psz_name ? strlen( p_item->psz_name ) : 0;
 
-        /* skip "." and ".." items */
-        if( ( i_name_len == 1 && p_item->psz_name[0] == '.' ) ||
+        /* skip "." and ".." and hidden files if option is activated */
+        if( ( !b_show_hiddenfiles && i_name_len > 0 &&
+              p_item->psz_name[0] == '.' ) ||
+            ( i_name_len == 1 && p_item->psz_name[0] == '.' ) ||
             ( i_name_len == 2 && p_item->psz_name[0] == '.' &&
               p_item->psz_name[1] == '.' ) ||
             has_ext( psz_ignored_exts, p_item->psz_name ))
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 0d8941a..031d91a 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1119,6 +1119,9 @@ static const char *const psz_sort_list_text[] = {
         "This is useful if you add directories that contain playlist files " \
         "for instance. Use a comma-separated list of extensions." )
 
+#define SHOW_HIDDENFILES_TEXT N_("Show hidden files")
+#define SHOW_HIDDENFILES_LONGTEXT N_( \
+        "Ignore files starting with '.'" )
 
 #define METADATA_NETWORK_TEXT N_( "Allow metadata network access" )
 
@@ -2051,6 +2054,9 @@ vlc_module_begin ()
     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( "show-hiddenfiles", false,
+               SHOW_HIDDENFILES_TEXT, SHOW_HIDDENFILES_LONGTEXT, false )
+
     add_obsolete_integer( "album-art" )
     add_bool( "metadata-network-access", false, METADATA_NETWORK_TEXT,
                  METADATA_NETWORK_TEXT, false )
-- 
2.1.4




More information about the vlc-devel mailing list