[vlc-commits] libvlc: add "extractor-flatten" option

Thomas Guillem git at videolan.org
Thu Oct 12 13:45:27 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Oct 12 13:26:45 2017 +0200| [780bf2cf517f493b9ad20ff9da156ab7ca9b0f89] | committer: Thomas Guillem

libvlc: add "extractor-flatten" option

Used to force extractors to flatten their file listing (done automatically by
vlc_readdir_helper helper).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=780bf2cf517f493b9ad20ff9da156ab7ca9b0f89
---

 include/vlc_input_item.h |  1 +
 src/input/item.c         | 20 +++++++++++++++-----
 src/libvlc-module.c      |  7 +++++++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index d0f9587b7a..f64cfc9b80 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -425,6 +425,7 @@ struct vlc_readdir_helper
     size_t i_dirs;
     int i_sub_autodetect_fuzzy;
     bool b_show_hiddenfiles;
+    bool b_flatten;
     char *psz_ignored_exts;
 };
 
diff --git a/src/input/item.c b/src/input/item.c
index 99cf6a2066..0327e21f03 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1686,6 +1686,7 @@ void vlc_readdir_helper_init(struct vlc_readdir_helper *p_rdh,
     bool b_autodetect = var_InheritBool(p_obj, "sub-autodetect-file");
     p_rdh->i_sub_autodetect_fuzzy = !b_autodetect ? 0 :
         var_InheritInteger(p_obj, "sub-autodetect-fuzzy");
+    p_rdh->b_flatten = var_InheritBool(p_obj, "extractor-flatten");
     TAB_INIT(p_rdh->i_slaves, p_rdh->pp_slaves);
     TAB_INIT(p_rdh->i_dirs, p_rdh->pp_dirs);
 
@@ -1728,13 +1729,22 @@ int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
     struct rdh_slave *p_rdh_slave = NULL;
     assert(psz_flatpath || psz_filename);
 
-    if (psz_filename == NULL)
+    if (!p_rdh->b_flatten)
     {
-        psz_filename = strrchr(psz_flatpath, '/');
-        if (psz_filename != NULL)
-            ++psz_filename;
-        else
+        if (psz_filename == NULL)
+        {
+            psz_filename = strrchr(psz_flatpath, '/');
+            if (psz_filename != NULL)
+                ++psz_filename;
+            else
+                psz_filename = psz_flatpath;
+        }
+    }
+    else
+    {
+        if (psz_filename == NULL)
             psz_filename = psz_flatpath;
+        psz_flatpath = NULL;
     }
 
     if (p_rdh->i_sub_autodetect_fuzzy != 0
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 6fe8e92ff6..7e1d90be15 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1138,6 +1138,11 @@ static const char *const psz_recursive_list_text[] = {
 #define SHOW_HIDDENFILES_LONGTEXT N_( \
         "Ignore files starting with '.'" )
 
+#define EXTRACTOR_FLATTEN_TEXT N_( \
+        "Flatten files listed by extractors (archive)")
+#define EXTRACTOR_FLATTEN_LONGTEXT N_( \
+        "The default behavior is to create one item per directory.")
+
 #define SD_TEXT N_( "Services discovery modules")
 #define SD_LONGTEXT N_( \
      "Specifies the services discovery modules to preload, separated by " \
@@ -2099,6 +2104,8 @@ vlc_module_begin ()
                 IGNORE_TEXT, IGNORE_LONGTEXT, false )
     add_bool( "show-hiddenfiles", false,
               SHOW_HIDDENFILES_TEXT, SHOW_HIDDENFILES_LONGTEXT, false )
+    add_bool( "extractor-flatten", false,
+              EXTRACTOR_FLATTEN_TEXT, EXTRACTOR_FLATTEN_LONGTEXT, true );
 
     set_subcategory( SUBCAT_PLAYLIST_SD )
     add_string( "services-discovery", "", SD_TEXT, SD_LONGTEXT, true )



More information about the vlc-commits mailing list