[vlc-commits] input: rename access_fsdir to readdir_helper

Thomas Guillem git at videolan.org
Wed Sep 20 16:57:10 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Sep 20 10:01:06 2017 +0200| [a234f55fc80ac14ba8010108cfdb7b4ad9c3fbee] | committer: Thomas Guillem

input: rename access_fsdir to readdir_helper

This helper can now be used by other modules like "stream directory".

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

 include/vlc_input_item.h    |  30 ++++----
 modules/access/directory.c  |   8 +-
 modules/access/dsm/access.c |  22 +++---
 modules/access/ftp.c        |  10 +--
 modules/access/nfs.c        |  20 ++---
 modules/access/sftp.c       |  10 +--
 modules/access/smb.c        |  10 +--
 src/input/item.c            | 183 ++++++++++++++++++++++----------------------
 src/libvlccore.sym          |   6 +-
 9 files changed, 151 insertions(+), 148 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index b5932607e8..5c16f70caf 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -412,11 +412,11 @@ struct input_stats_t
 
 /**
  * Access pf_readdir helper struct
- * \see access_fsdir_init()
- * \see access_fsdir_additem()
- * \see access_fsdir_finish()
+ * \see readdir_helper_init()
+ * \see readdir_helper_additem()
+ * \see readdir_helper_finish()
  */
-struct access_fsdir
+struct readdir_helper
 {
     input_item_node_t *p_node;
     void **pp_slaves;
@@ -427,32 +427,34 @@ struct access_fsdir
 };
 
 /**
- * Init a access_fsdir struct
+ * Init a readdir_helper struct
  *
- * \param p_fsdir need to be cleaned with access_fsdir_finish()
+ * \param p_rdh need to be cleaned with readdir_helper_finish()
  * \param p_node node that will be used to add items
  */
-VLC_API void access_fsdir_init(struct access_fsdir *p_fsdir,
-                               stream_t *p_access, input_item_node_t *p_node);
+VLC_API void readdir_helper_init(struct readdir_helper *p_rdh,
+                                 vlc_object_t *p_obj, input_item_node_t *p_node);
+#define readdir_helper_init(p_rdh, p_obj, p_node) \
+    readdir_helper_init(p_rdh, VLC_OBJECT(p_obj), p_node)
 
 /**
  * Finish adding items to the node
  *
  * \param b_success if true, items of the node will be sorted.
  */
-VLC_API void access_fsdir_finish(struct access_fsdir *p_fsdir, bool b_success);
+VLC_API void readdir_helper_finish(struct readdir_helper *p_rdh, bool b_success);
 
 /**
- * Add a new input_item_t entry to the node of the access_fsdir struct.
+ * Add a new input_item_t entry to the node of the readdir_helper struct.
  *
- * \param p_fsdir previously inited access_fsdir struct
+ * \param p_rdh previously inited readdir_helper struct
  * \param psz_uri uri of the new item
  * \param psz_filename file name of the new item
  * \param i_type see \ref input_item_type_e
  * \param i_net see \ref input_item_net_type
  */
-VLC_API int access_fsdir_additem(struct access_fsdir *p_fsdir,
-                                 const char *psz_uri, const char *psz_filename,
-                                 int i_type, int i_net);
+VLC_API int readdir_helper_additem(struct readdir_helper *p_rdh,
+                                   const char *psz_uri, const char *psz_filename,
+                                   int i_type, int i_net);
 
 #endif
diff --git a/modules/access/directory.c b/modules/access/directory.c
index b4e2d774d1..3f9b0b62fd 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -117,8 +117,8 @@ int DirRead (stream_t *access, input_item_node_t *node)
 
     bool special_files = var_InheritBool(access, "list-special-files");
 
-    struct access_fsdir fsdir;
-    access_fsdir_init(&fsdir, access, node);
+    struct readdir_helper rdh;
+    readdir_helper_init(&rdh, access, node);
 
     while (ret == VLC_SUCCESS && (entry = vlc_readdir(sys->dir)) != NULL)
     {
@@ -181,11 +181,11 @@ int DirRead (stream_t *access, input_item_node_t *node)
             ret = VLC_ENOMEM;
             break;
         }
-        ret = access_fsdir_additem(&fsdir, uri, entry, type, ITEM_NET_UNKNOWN);
+        ret = readdir_helper_additem(&rdh, uri, entry, type, ITEM_NET_UNKNOWN);
         free(uri);
     }
 
-    access_fsdir_finish(&fsdir, ret == VLC_SUCCESS);
+    readdir_helper_finish(&rdh, ret == VLC_SUCCESS);
 
     return ret;
 }
diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
index 17ec31d04e..6bbe3ebf32 100644
--- a/modules/access/dsm/access.c
+++ b/modules/access/dsm/access.c
@@ -98,7 +98,7 @@ static int BrowserInit( stream_t *p_access );
 static int get_address( stream_t *p_access );
 static int login( stream_t *p_access );
 static bool get_path( stream_t *p_access );
-static int add_item( stream_t *p_access,  struct access_fsdir *p_fsdir,
+static int add_item( stream_t *p_access,  struct readdir_helper *p_rdh,
                      const char *psz_name, int i_type );
 
 struct access_sys_t
@@ -511,7 +511,7 @@ static int Control( stream_t *p_access, int i_query, va_list args )
     return VLC_SUCCESS;
 }
 
-static int add_item( stream_t *p_access, struct access_fsdir *p_fsdir,
+static int add_item( stream_t *p_access, struct readdir_helper *p_rdh,
                      const char *psz_name, int i_type )
 {
     char         *psz_uri;
@@ -529,7 +529,7 @@ static int add_item( stream_t *p_access, struct access_fsdir *p_fsdir,
     if( i_ret == -1 )
         return VLC_ENOMEM;
 
-    return access_fsdir_additem( p_fsdir, psz_uri, psz_name, i_type, ITEM_NET );
+    return readdir_helper_additem( p_rdh, psz_uri, psz_name, i_type, ITEM_NET );
 }
 
 static int BrowseShare( stream_t *p_access, input_item_node_t *p_node )
@@ -544,8 +544,8 @@ static int BrowseShare( stream_t *p_access, input_item_node_t *p_node )
         != DSM_SUCCESS )
         return VLC_EGENERIC;
 
-    struct access_fsdir fsdir;
-    access_fsdir_init( &fsdir, p_access, p_node );
+    struct readdir_helper rdh;
+    readdir_helper_init( &rdh, p_access, p_node );
 
     for( size_t i = 0; i < share_count && i_ret == VLC_SUCCESS; i++ )
     {
@@ -554,10 +554,10 @@ static int BrowseShare( stream_t *p_access, input_item_node_t *p_node )
         if( psz_name[strlen( psz_name ) - 1] == '$')
             continue;
 
-        i_ret = add_item( p_access, &fsdir, psz_name, ITEM_TYPE_DIRECTORY );
+        i_ret = add_item( p_access, &rdh, psz_name, ITEM_TYPE_DIRECTORY );
     }
 
-    access_fsdir_finish( &fsdir, i_ret == VLC_SUCCESS );
+    readdir_helper_finish( &rdh, i_ret == VLC_SUCCESS );
 
     smb_share_list_destroy( shares );
     return i_ret;
@@ -586,8 +586,8 @@ static int BrowseDirectory( stream_t *p_access, input_item_node_t *p_node )
     if( files == NULL )
         return VLC_EGENERIC;
 
-    struct access_fsdir fsdir;
-    access_fsdir_init( &fsdir, p_access, p_node );
+    struct readdir_helper rdh;
+    readdir_helper_init( &rdh, p_access, p_node );
 
     files_count = smb_stat_list_count( files );
     for( size_t i = 0; i < files_count && i_ret == VLC_SUCCESS; i++ )
@@ -605,10 +605,10 @@ static int BrowseDirectory( stream_t *p_access, input_item_node_t *p_node )
 
         i_type = smb_stat_get( st, SMB_STAT_ISDIR ) ?
                  ITEM_TYPE_DIRECTORY : ITEM_TYPE_FILE;
-        i_ret = add_item( p_access, &fsdir, psz_name, i_type );
+        i_ret = add_item( p_access, &rdh, psz_name, i_type );
     }
 
-    access_fsdir_finish( &fsdir, i_ret == VLC_SUCCESS );
+    readdir_helper_finish( &rdh, i_ret == VLC_SUCCESS );
 
     smb_stat_list_destroy( files );
     return i_ret;
diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 05d7196fec..3a3c4105e2 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -911,8 +911,8 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_current_node)
     assert( p_sys->data != NULL );
     assert( !p_sys->out );
 
-    struct access_fsdir fsdir;
-    access_fsdir_init( &fsdir, p_access, p_current_node );
+    struct readdir_helper rdh;
+    readdir_helper_init( &rdh, p_access, p_current_node );
 
     while (i_ret == VLC_SUCCESS)
     {
@@ -956,15 +956,15 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_current_node)
                       p_sys->url.psz_path ? p_sys->url.psz_path : "",
                       psz_filename ) != -1 )
         {
-            i_ret = access_fsdir_additem( &fsdir, psz_uri, psz_file,
-                                          type, ITEM_NET );
+            i_ret = readdir_helper_additem( &rdh, psz_uri, psz_file,
+                                            type, ITEM_NET );
             free( psz_uri );
         }
         free( psz_filename );
         free( psz_line );
     }
 
-    access_fsdir_finish( &fsdir, i_ret == VLC_SUCCESS );
+    readdir_helper_finish( &rdh, i_ret == VLC_SUCCESS );
     return i_ret;
 }
 
diff --git a/modules/access/nfs.c b/modules/access/nfs.c
index 2de2c6256e..93bbe4f0e7 100644
--- a/modules/access/nfs.c
+++ b/modules/access/nfs.c
@@ -329,8 +329,8 @@ DirRead(stream_t *p_access, input_item_node_t *p_node)
     int i_ret = VLC_SUCCESS;
     assert(p_sys->p_nfsdir);
 
-    struct access_fsdir fsdir;
-    access_fsdir_init(&fsdir, p_access, p_node);
+    struct readdir_helper rdh;
+    readdir_helper_init(&rdh, p_access, p_node);
 
     while (i_ret == VLC_SUCCESS
         && (p_nfsdirent = nfs_readdir(p_sys->p_nfs, p_sys->p_nfsdir)) != NULL)
@@ -361,12 +361,12 @@ DirRead(stream_t *p_access, input_item_node_t *p_node)
         default:
             i_type = ITEM_TYPE_UNKNOWN;
         }
-        i_ret = access_fsdir_additem(&fsdir, psz_url, p_nfsdirent->name,
-                                     i_type, ITEM_NET);
+        i_ret = readdir_helper_additem(&rdh, psz_url, p_nfsdirent->name,
+                                       i_type, ITEM_NET);
         free(psz_url);
     }
 
-    access_fsdir_finish(&fsdir, i_ret == VLC_SUCCESS);
+    readdir_helper_finish(&rdh, i_ret == VLC_SUCCESS);
 
     return i_ret;
 }
@@ -378,8 +378,8 @@ MountRead(stream_t *p_access, input_item_node_t *p_node)
     assert(p_sys->p_mount != NULL && p_sys->res.exports.i_count >= 0);
     int i_ret = VLC_SUCCESS;
 
-    struct access_fsdir fsdir;
-    access_fsdir_init(&fsdir, p_access, p_node);
+    struct readdir_helper rdh;
+    readdir_helper_init(&rdh, p_access, p_node);
 
     for (int i = 0; i < p_sys->res.exports.i_count && i_ret == VLC_SUCCESS; ++i)
     {
@@ -391,12 +391,12 @@ MountRead(stream_t *p_access, input_item_node_t *p_node)
             i_ret = VLC_ENOMEM;
             break;
         }
-        i_ret = access_fsdir_additem(&fsdir, psz_url, psz_name,
-                                     ITEM_TYPE_DIRECTORY, ITEM_NET);
+        i_ret = readdir_helper_additem(&rdh, psz_url, psz_name,
+                                       ITEM_TYPE_DIRECTORY, ITEM_NET);
         free(psz_url);
     }
 
-    access_fsdir_finish(&fsdir, i_ret == VLC_SUCCESS);
+    readdir_helper_finish(&rdh, i_ret == VLC_SUCCESS);
 
     return i_ret;
 }
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index d91670875f..e46d6c64d7 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -547,8 +547,8 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_current_node)
     if( !psz_file )
         return VLC_ENOMEM;
 
-    struct access_fsdir fsdir;
-    access_fsdir_init( &fsdir, p_access, p_current_node );
+    struct readdir_helper rdh;
+    readdir_helper_init( &rdh, p_access, p_current_node );
 
     while( i_ret == VLC_SUCCESS
         && 0 != ( err = libssh2_sftp_readdir( p_sys->file, psz_file, i_size, &attrs ) ) )
@@ -589,12 +589,12 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_current_node)
         free( psz_uri );
 
         int i_type = LIBSSH2_SFTP_S_ISDIR( attrs.permissions ) ? ITEM_TYPE_DIRECTORY : ITEM_TYPE_FILE;
-        i_ret = access_fsdir_additem( &fsdir, psz_full_uri, psz_file, i_type,
-                                      ITEM_NET );
+        i_ret = readdir_helper_additem( &rdh, psz_full_uri, psz_file, i_type,
+                                        ITEM_NET );
         free( psz_full_uri );
     }
 
-    access_fsdir_finish( &fsdir, i_ret == VLC_SUCCESS );
+    readdir_helper_finish( &rdh, i_ret == VLC_SUCCESS );
     free( psz_file );
     return i_ret;
 }
diff --git a/modules/access/smb.c b/modules/access/smb.c
index 6a898fd959..47e459f098 100644
--- a/modules/access/smb.c
+++ b/modules/access/smb.c
@@ -340,8 +340,8 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_node )
     struct smbc_dirent *p_entry;
     int i_ret = VLC_SUCCESS;
 
-    struct access_fsdir fsdir;
-    access_fsdir_init( &fsdir, p_access, p_node );
+    struct readdir_helper rdh;
+    readdir_helper_init( &rdh, p_access, p_node );
 
     while( i_ret == VLC_SUCCESS && ( p_entry = smbc_readdir( p_sys->i_smb ) ) )
     {
@@ -388,12 +388,12 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_node )
             break;
         }
         free(psz_encoded_name);
-        i_ret = access_fsdir_additem( &fsdir, psz_uri, p_entry->name,
-                                      i_type, ITEM_NET );
+        i_ret = readdir_helper_additem( &rdh, psz_uri, p_entry->name,
+                                        i_type, ITEM_NET );
         free( psz_uri );
     }
 
-    access_fsdir_finish( &fsdir, i_ret == VLC_SUCCESS );
+    readdir_helper_finish( &rdh, i_ret == VLC_SUCCESS );
 
     return i_ret;
 }
diff --git a/src/input/item.c b/src/input/item.c
index 56faff5c19..c7ef944f8c 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1322,7 +1322,7 @@ void input_item_UpdateTracksInfo(input_item_t *item, const es_format_t *fmt)
     vlc_mutex_unlock( &item->lock );
 }
 
-static int compar_type(input_item_t *p1, input_item_t *p2)
+static int rdh_compar_type(input_item_t *p1, input_item_t *p2)
 {
     if (p1->i_type != p2->i_type)
     {
@@ -1334,19 +1334,19 @@ static int compar_type(input_item_t *p1, input_item_t *p2)
     return 0;
 }
 
-static int compar_filename(const void *a, const void *b)
+static int rdh_compar_filename(const void *a, const void *b)
 {
     input_item_node_t *const *na = a, *const *nb = b;
     input_item_t *ia = (*na)->p_item, *ib = (*nb)->p_item;
 
-    int i_ret = compar_type(ia, ib);
+    int i_ret = rdh_compar_type(ia, ib);
     if (i_ret != 0)
         return i_ret;
 
     return vlc_filenamecmp(ia->psz_name, ib->psz_name);
 }
 
-static void fsdir_sort(input_item_node_t *p_node)
+static void rdh_sort(input_item_node_t *p_node)
 {
     if (p_node->i_children <= 0)
         return;
@@ -1358,7 +1358,7 @@ static void fsdir_sort(input_item_node_t *p_node)
 
     /* Sort current node */
     qsort(p_node->pp_children, p_node->i_children,
-          sizeof(input_item_node_t *), compar_filename);
+          sizeof(input_item_node_t *), rdh_compar_filename);
 
     /* Unlock all children */
     for (int i = 0; i < p_node->i_children; i++)
@@ -1366,14 +1366,14 @@ static void fsdir_sort(input_item_node_t *p_node)
 
     /* Sort all children */
     for (int i = 0; i < p_node->i_children; i++)
-        fsdir_sort(p_node->pp_children[i]);
+        rdh_sort(p_node->pp_children[i]);
 }
 
 /**
  * Does the provided file name has one of the extension provided ?
  */
-static bool fsdir_has_ext(const char *psz_filename,
-                          const char *psz_ignored_exts)
+static bool rdh_file_has_ext(const char *psz_filename,
+                             const char *psz_ignored_exts)
 {
     if (psz_ignored_exts == NULL)
         return false;
@@ -1400,24 +1400,24 @@ static bool fsdir_has_ext(const char *psz_filename,
     return false;
 }
 
-static bool fsdir_is_ignored(struct access_fsdir *p_fsdir,
-                             const char *psz_filename)
+static bool rdh_file_is_ignored(struct readdir_helper *p_rdh,
+                           const char *psz_filename)
 {
     return (psz_filename[0] == '\0'
          || strcmp(psz_filename, ".") == 0
          || strcmp(psz_filename, "..") == 0
-         || (!p_fsdir->b_show_hiddenfiles && psz_filename[0] == '.')
-         || fsdir_has_ext(psz_filename, p_fsdir->psz_ignored_exts));
+         || (!p_rdh->b_show_hiddenfiles && psz_filename[0] == '.')
+         || rdh_file_has_ext(psz_filename, p_rdh->psz_ignored_exts));
 }
 
-struct fsdir_slave
+struct rdh_slave
 {
     input_item_slave_t *p_slave;
     char *psz_filename;
     input_item_node_t *p_node;
 };
 
-static char *fsdir_name_from_filename(const char *psz_filename)
+static char *rdh_name_from_filename(const char *psz_filename)
 {
     /* remove leading white spaces */
     while (*psz_filename != '\0' && *psz_filename == ' ')
@@ -1448,13 +1448,13 @@ static char *fsdir_name_from_filename(const char *psz_filename)
     return psz_name;
 }
 
-static uint8_t fsdir_get_slave_priority(input_item_t *p_item,
-                                        input_item_slave_t *p_slave,
-                                        const char *psz_slave_filename)
+static uint8_t rdh_get_slave_priority(input_item_t *p_item,
+                                      input_item_slave_t *p_slave,
+                                      const char *psz_slave_filename)
 {
     uint8_t i_priority = SLAVE_PRIORITY_MATCH_NONE;
-    char *psz_item_name = fsdir_name_from_filename(p_item->psz_name);
-    char *psz_slave_name = fsdir_name_from_filename(psz_slave_filename);
+    char *psz_item_name = rdh_name_from_filename(p_item->psz_name);
+    char *psz_slave_name = rdh_name_from_filename(psz_slave_filename);
 
     if (!psz_item_name || !psz_slave_name)
         goto done;
@@ -1498,10 +1498,10 @@ done:
     return i_priority;
 }
 
-static int fsdir_should_match_idx(struct access_fsdir *p_fsdir,
-                                  struct fsdir_slave *p_fsdir_sub)
+static int rdh_should_match_idx(struct readdir_helper *p_rdh,
+                                struct rdh_slave *p_rdh_sub)
 {
-    char *psz_ext = strrchr(p_fsdir_sub->psz_filename, '.');
+    char *psz_ext = strrchr(p_rdh_sub->psz_filename, '.');
     if (!psz_ext)
         return false;
     psz_ext++;
@@ -1509,25 +1509,25 @@ static int fsdir_should_match_idx(struct access_fsdir *p_fsdir,
     if (strcasecmp(psz_ext, "sub") != 0)
         return false;
 
-    for (unsigned int i = 0; i < p_fsdir->i_slaves; i++)
+    for (unsigned int i = 0; i < p_rdh->i_slaves; i++)
     {
-        struct fsdir_slave *p_fsdir_slave = p_fsdir->pp_slaves[i];
+        struct rdh_slave *p_rdh_slave = p_rdh->pp_slaves[i];
 
-        if (p_fsdir_slave == NULL || p_fsdir_slave == p_fsdir_sub)
+        if (p_rdh_slave == NULL || p_rdh_slave == p_rdh_sub)
             continue;
 
         /* check that priorities match */
-        if (p_fsdir_slave->p_slave->i_priority !=
-            p_fsdir_sub->p_slave->i_priority)
+        if (p_rdh_slave->p_slave->i_priority !=
+            p_rdh_sub->p_slave->i_priority)
             continue;
 
         /* check that the filenames without extension match */
-        if (strncasecmp(p_fsdir_sub->psz_filename, p_fsdir_slave->psz_filename,
-                        strlen(p_fsdir_sub->psz_filename) - 3 ) != 0)
+        if (strncasecmp(p_rdh_sub->psz_filename, p_rdh_slave->psz_filename,
+                        strlen(p_rdh_sub->psz_filename) - 3 ) != 0)
             continue;
 
         /* check that we have an idx file */
-        char *psz_ext_idx = strrchr(p_fsdir_slave->psz_filename, '.');
+        char *psz_ext_idx = strrchr(p_rdh_slave->psz_filename, '.');
         if (psz_ext_idx == NULL)
             continue;
         psz_ext_idx++;
@@ -1537,42 +1537,42 @@ static int fsdir_should_match_idx(struct access_fsdir *p_fsdir,
     return false;
 }
 
-static void fsdir_attach_slaves(struct access_fsdir *p_fsdir)
+static void rdh_attach_slaves(struct readdir_helper *p_rdh)
 {
-    if (p_fsdir->i_sub_autodetect_fuzzy == 0)
+    if (p_rdh->i_sub_autodetect_fuzzy == 0)
         return;
 
     /* Try to match slaves for each items of the node */
-    for (int i = 0; i < p_fsdir->p_node->i_children; i++)
+    for (int i = 0; i < p_rdh->p_node->i_children; i++)
     {
-        input_item_node_t *p_node = p_fsdir->p_node->pp_children[i];
+        input_item_node_t *p_node = p_rdh->p_node->pp_children[i];
         input_item_t *p_item = p_node->p_item;
 
-        for (unsigned int j = 0; j < p_fsdir->i_slaves; j++)
+        for (unsigned int j = 0; j < p_rdh->i_slaves; j++)
         {
-            struct fsdir_slave *p_fsdir_slave = p_fsdir->pp_slaves[j];
+            struct rdh_slave *p_rdh_slave = p_rdh->pp_slaves[j];
 
             /* Don't try to match slaves with themselves or slaves already
              * attached with the higher priority */
-            if (p_fsdir_slave->p_node == p_node
-             || p_fsdir_slave->p_slave->i_priority == SLAVE_PRIORITY_MATCH_ALL)
+            if (p_rdh_slave->p_node == p_node
+             || p_rdh_slave->p_slave->i_priority == SLAVE_PRIORITY_MATCH_ALL)
                 continue;
 
             uint8_t i_priority =
-                fsdir_get_slave_priority(p_item, p_fsdir_slave->p_slave,
-                                         p_fsdir_slave->psz_filename);
+                rdh_get_slave_priority(p_item, p_rdh_slave->p_slave,
+                                         p_rdh_slave->psz_filename);
 
-            if (i_priority < p_fsdir->i_sub_autodetect_fuzzy)
+            if (i_priority < p_rdh->i_sub_autodetect_fuzzy)
                 continue;
 
             /* Drop the ".sub" slave if a ".idx" slave matches */
-            if (p_fsdir_slave->p_slave->i_type == SLAVE_TYPE_SPU
-             && fsdir_should_match_idx(p_fsdir, p_fsdir_slave))
+            if (p_rdh_slave->p_slave->i_type == SLAVE_TYPE_SPU
+             && rdh_should_match_idx(p_rdh, p_rdh_slave))
                 continue;
 
             input_item_slave_t *p_slave =
-                input_item_slave_New(p_fsdir_slave->p_slave->psz_uri,
-                                     p_fsdir_slave->p_slave->i_type,
+                input_item_slave_New(p_rdh_slave->p_slave->psz_uri,
+                                     p_rdh_slave->p_slave->i_type,
                                      i_priority);
             if (p_slave == NULL)
                 break;
@@ -1585,84 +1585,85 @@ static void fsdir_attach_slaves(struct access_fsdir *p_fsdir)
 
             /* Remove the corresponding node if any: This slave won't be
              * added in the parent node */
-            if (p_fsdir_slave->p_node != NULL)
+            if (p_rdh_slave->p_node != NULL)
             {
-                input_item_node_RemoveNode(p_fsdir->p_node,
-                                           p_fsdir_slave->p_node);
-                input_item_node_Delete(p_fsdir_slave->p_node);
-                p_fsdir_slave->p_node = NULL;
+                input_item_node_RemoveNode(p_rdh->p_node,
+                                           p_rdh_slave->p_node);
+                input_item_node_Delete(p_rdh_slave->p_node);
+                p_rdh_slave->p_node = NULL;
             }
 
-            p_fsdir_slave->p_slave->i_priority = i_priority;
+            p_rdh_slave->p_slave->i_priority = i_priority;
         }
     }
 }
 
-void access_fsdir_init(struct access_fsdir *p_fsdir,
-                       stream_t *p_access, input_item_node_t *p_node)
+#undef readdir_helper_init
+void readdir_helper_init(struct readdir_helper *p_rdh,
+                         vlc_object_t *p_obj, input_item_node_t *p_node)
 {
-    p_fsdir->p_node = p_node;
-    p_fsdir->b_show_hiddenfiles = var_InheritBool(p_access, "show-hiddenfiles");
-    p_fsdir->psz_ignored_exts = var_InheritString(p_access, "ignore-filetypes");
-    bool b_autodetect = var_InheritBool(p_access, "sub-autodetect-file");
-    p_fsdir->i_sub_autodetect_fuzzy = !b_autodetect ? 0 :
-        var_InheritInteger(p_access, "sub-autodetect-fuzzy");
-    TAB_INIT(p_fsdir->i_slaves, p_fsdir->pp_slaves);
+    p_rdh->p_node = p_node;
+    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");
+    p_rdh->i_sub_autodetect_fuzzy = !b_autodetect ? 0 :
+        var_InheritInteger(p_obj, "sub-autodetect-fuzzy");
+    TAB_INIT(p_rdh->i_slaves, p_rdh->pp_slaves);
 }
 
-void access_fsdir_finish(struct access_fsdir *p_fsdir, bool b_success)
+void readdir_helper_finish(struct readdir_helper *p_rdh, bool b_success)
 {
     if (b_success)
     {
-        fsdir_attach_slaves(p_fsdir);
-        fsdir_sort(p_fsdir->p_node);
+        rdh_attach_slaves(p_rdh);
+        rdh_sort(p_rdh->p_node);
     }
-    free(p_fsdir->psz_ignored_exts);
+    free(p_rdh->psz_ignored_exts);
 
     /* Remove unmatched slaves */
-    for (unsigned int i = 0; i < p_fsdir->i_slaves; i++)
+    for (unsigned int i = 0; i < p_rdh->i_slaves; i++)
     {
-        struct fsdir_slave *p_fsdir_slave = p_fsdir->pp_slaves[i];
-        if (p_fsdir_slave != NULL)
+        struct rdh_slave *p_rdh_slave = p_rdh->pp_slaves[i];
+        if (p_rdh_slave != NULL)
         {
-            input_item_slave_Delete(p_fsdir_slave->p_slave);
-            free(p_fsdir_slave->psz_filename);
-            free(p_fsdir_slave);
+            input_item_slave_Delete(p_rdh_slave->p_slave);
+            free(p_rdh_slave->psz_filename);
+            free(p_rdh_slave);
         }
     }
-    TAB_CLEAN(p_fsdir->i_slaves, p_fsdir->pp_slaves);
+    TAB_CLEAN(p_rdh->i_slaves, p_rdh->pp_slaves);
 }
 
-int access_fsdir_additem(struct access_fsdir *p_fsdir,
-                         const char *psz_uri, const char *psz_filename,
-                         int i_type, int i_net)
+int readdir_helper_additem(struct readdir_helper *p_rdh,
+                           const char *psz_uri, const char *psz_filename,
+                           int i_type, int i_net)
 {
     enum slave_type i_slave_type;
-    struct fsdir_slave *p_fsdir_slave = NULL;
+    struct rdh_slave *p_rdh_slave = NULL;
     input_item_node_t *p_node;
 
-    if (p_fsdir->i_sub_autodetect_fuzzy != 0
+    if (p_rdh->i_sub_autodetect_fuzzy != 0
      && input_item_slave_GetType(psz_filename, &i_slave_type))
     {
-        p_fsdir_slave = malloc(sizeof(*p_fsdir_slave));
-        if (!p_fsdir_slave)
+        p_rdh_slave = malloc(sizeof(*p_rdh_slave));
+        if (!p_rdh_slave)
             return VLC_ENOMEM;
 
-        p_fsdir_slave->p_node = NULL;
-        p_fsdir_slave->psz_filename = strdup(psz_filename);
-        p_fsdir_slave->p_slave = input_item_slave_New(psz_uri, i_slave_type,
+        p_rdh_slave->p_node = NULL;
+        p_rdh_slave->psz_filename = strdup(psz_filename);
+        p_rdh_slave->p_slave = input_item_slave_New(psz_uri, i_slave_type,
                                                       SLAVE_PRIORITY_MATCH_NONE);
-        if (!p_fsdir_slave->p_slave || !p_fsdir_slave->psz_filename)
+        if (!p_rdh_slave->p_slave || !p_rdh_slave->psz_filename)
         {
-            free(p_fsdir_slave->psz_filename);
-            free(p_fsdir_slave);
+            free(p_rdh_slave->psz_filename);
+            free(p_rdh_slave);
             return VLC_ENOMEM;
         }
 
-        TAB_APPEND(p_fsdir->i_slaves, p_fsdir->pp_slaves, p_fsdir_slave);
+        TAB_APPEND(p_rdh->i_slaves, p_rdh->pp_slaves, p_rdh_slave);
     }
 
-    if (fsdir_is_ignored(p_fsdir, psz_filename))
+    if (rdh_file_is_ignored(p_rdh, psz_filename))
         return VLC_SUCCESS;
 
     input_item_t *p_item = input_item_NewExt(psz_uri, psz_filename, -1,
@@ -1670,14 +1671,14 @@ int access_fsdir_additem(struct access_fsdir *p_fsdir,
     if (p_item == NULL)
         return VLC_ENOMEM;
 
-    input_item_CopyOptions(p_item, p_fsdir->p_node->p_item);
-    p_node = input_item_node_AppendItem(p_fsdir->p_node, p_item);
+    input_item_CopyOptions(p_item, p_rdh->p_node->p_item);
+    p_node = input_item_node_AppendItem(p_rdh->p_node, p_item);
     input_item_Release(p_item);
 
     /* A slave can also be an item. If there is a match, this item will be
      * removed from the parent node. This is not a common case, since most
-     * slaves will be ignored by fsdir_is_ignored() */
-    if (p_fsdir_slave != NULL)
-        p_fsdir_slave->p_node = p_node;
+     * slaves will be ignored by rdh_file_is_ignored() */
+    if (p_rdh_slave != NULL)
+        p_rdh_slave->p_node = p_node;
     return VLC_SUCCESS;
 }
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 4f0bf20dbc..10b2b9c103 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -1,8 +1,5 @@
 access_vaDirectoryControlHelper
 vlc_access_NewMRL
-access_fsdir_init
-access_fsdir_finish
-access_fsdir_additem
 AddMD5
 aout_BitsPerSample
 aout_ChannelExtract
@@ -363,6 +360,9 @@ playlist_VolumeUp
 playlist_MuteSet
 playlist_MuteGet
 playlist_SetRenderer
+readdir_helper_init
+readdir_helper_finish
+readdir_helper_additem
 sdp_AddAttribute
 sdp_AddMedia
 secstotimestr



More information about the vlc-commits mailing list