[vlc-devel] [PATCH 3/3] input: item: ignore directories if --recursive=none

Filip Roséen filip at atch.se
Fri Jul 20 11:55:19 CEST 2018


Hi again,

As the patch in which this email is a reply to includes an
*ABI*-breaking change, it cannot be backported to `3.0.0` *as-is*.

I am not sure how many users rely on `--recursive=none`, though it's
probably not many as it has been broken for quite some time, and I
could not find a single ticket or post that asks about the breakage.
With that in mind we have a few options:

  1. remove support for `--recursive=none`, conditionally supporting
     it in *trunk* (though if removed in one, it is probably best to
     do it in both).

  2. write a somewhat ugly backportable fix

Alternative 2 will be ugly as there is no good way of retrieving the
state of `--recursive` from within `rdh_file_is_ignored` nor
`vlc_readdir_helper_add_item`, unless I am missing something that is
not immediately obvious to me at the current time (sleep depravation).

One could, potentially, filter out directories when the items are
about to get added to the playlist, which is also very ugly (in my
opinion). The original implementation (from way way back) did the
filtering in that which spawned the items, which is a requirement I do
not want to impose on our current modules.

Input on the matter is more than welcome. I am not a fan of removing
options as it is hard to prove what is actually being used in the
world, but I could probably live with the removal of
`--recursive=none` .

Best Regards,\
Filip

On 2018-07-20 10:15, Filip Roséen wrote:

> fixes: #20865
> ---
>  include/vlc_input_item.h |  1 +
>  src/input/item.c         | 12 ++++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
> index 4bd07c1733..a78ae13c89 100644
> --- a/include/vlc_input_item.h
> +++ b/include/vlc_input_item.h
> @@ -440,6 +440,7 @@ struct vlc_readdir_helper
>      bool b_show_hiddenfiles;
>      bool b_flatten;
>      char *psz_ignored_exts;
> +    bool b_show_directories;
>  };
>  
>  /**
> diff --git a/src/input/item.c b/src/input/item.c
> index f288d23c7d..8cc65722b8 100644
> --- a/src/input/item.c
> +++ b/src/input/item.c
> @@ -1406,11 +1406,12 @@ static bool rdh_file_has_ext(const char *psz_filename,
>  }
>  
>  static bool rdh_file_is_ignored(struct vlc_readdir_helper *p_rdh,
> -                                const char *psz_filename)
> +                                const char *psz_filename, int i_type)
>  {
>      return (psz_filename[0] == '\0'
>           || strcmp(psz_filename, ".") == 0
>           || strcmp(psz_filename, "..") == 0
> +         || (!p_rdh->b_show_directories && i_type == ITEM_TYPE_DIRECTORY)
>           || (!p_rdh->b_show_hiddenfiles && psz_filename[0] == '.')
>           || rdh_file_has_ext(psz_filename, p_rdh->psz_ignored_exts));
>  }
> @@ -1706,7 +1707,14 @@ void vlc_readdir_helper_init(struct vlc_readdir_helper *p_rdh,
>          p_obj = p_var_obj;
>      }
>  
> +    char* psz_recursive = var_InheritString(p_obj, "recursive");
> +    bool b_show_directories = true;
> +    if (psz_recursive && !strcmp( psz_recursive, "none"))
> +        b_show_directories = false;
> +    free(psz_recursive);
> +
>      p_rdh->p_node = p_node;
> +    p_rdh->b_show_directories = b_show_directories;
>      p_rdh->b_show_hiddenfiles = var_InheritBool(p_obj, "show-hiddenfiles");
>      p_rdh->psz_ignored_exts = var_InheritString(p_obj, "ignore-filetypes");
>      bool b_autodetect = var_InheritBool(p_obj, "sub-autodetect-file");
> @@ -1794,7 +1802,7 @@ int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
>          TAB_APPEND(p_rdh->i_slaves, p_rdh->pp_slaves, p_rdh_slave);
>      }
>  
> -    if (rdh_file_is_ignored(p_rdh, psz_filename))
> +    if (rdh_file_is_ignored(p_rdh, psz_filename, i_type))
>          return VLC_SUCCESS;
>  
>      input_item_node_t *p_node = p_rdh->p_node;
> -- 
> 2.18.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20180720/8102aef7/attachment.html>


More information about the vlc-devel mailing list