[vlc-devel] [PATCH 3/7] dsm: change item b_net and i_type

Thomas Guillem thomas at gllm.fr
Tue Mar 24 18:22:16 CET 2015


Set b_net to true, and set ITEM_TYPE_DIRECTORY if the item is a share of a
directory.
---
 modules/access/dsm/access.c | 16 ++++++++++------
 modules/access/dsm/sd.c     |  4 ++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
index 6e30adc..d6c83f6 100644
--- a/modules/access/dsm/access.c
+++ b/modules/access/dsm/access.c
@@ -108,7 +108,7 @@ static int login( access_t *p_access );
 static void backslash_path( vlc_url_t *p_url );
 static bool get_path( access_t *p_access );
 static int add_item( access_t *p_access,  input_item_node_t *p_node,
-                     const char *psz_name );
+                     const char *psz_name, int i_type );
 
 struct access_sys_t
 {
@@ -560,7 +560,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
 }
 
 static int add_item( access_t *p_access, input_item_node_t *p_node,
-                     const char *psz_name )
+                     const char *psz_name, int i_type )
 {
     access_sys_t *p_sys = p_access->p_sys;
     input_item_t *p_item;
@@ -571,7 +571,8 @@ static int add_item( access_t *p_access, input_item_node_t *p_node,
     if( i_ret == -1 )
         return VLC_ENOMEM;
 
-    p_item = input_item_New( psz_uri, psz_name );
+    p_item = input_item_NewWithTypeExt( psz_uri, psz_name, 0, NULL, 0, -1,
+                                        i_type, 1 );
     free( psz_uri );
     if( p_item == NULL )
         return VLC_ENOMEM;
@@ -623,7 +624,7 @@ static int BrowseShare( access_t *p_access, input_item_node_t *p_node )
         if( psz_name[strlen( psz_name ) - 1] == '$')
             continue;
 
-        i_ret = add_item( p_access, p_node, psz_name );
+        i_ret = add_item( p_access, p_node, psz_name, ITEM_TYPE_DIRECTORY );
         if( i_ret != VLC_SUCCESS )
             goto error;
     }
@@ -662,6 +663,8 @@ static int BrowseDirectory( access_t *p_access, input_item_node_t *p_node )
     files_count = smb_stat_list_count( files );
     for( size_t i = 0; i < files_count; i++ )
     {
+        int i_type;
+
         st = smb_stat_list_at( files, i );
 
         if( st == NULL ) {
@@ -674,8 +677,9 @@ static int BrowseDirectory( access_t *p_access, input_item_node_t *p_node )
         /* Avoid infinite loop */
         if( !strcmp( psz_name, ".") || !strcmp( psz_name, "..") )
             continue;
-
-        i_ret = add_item( p_access, p_node, psz_name );
+        i_type = smb_stat_get( st, SMB_STAT_ISDIR ) ?
+                 ITEM_TYPE_DIRECTORY : ITEM_TYPE_FILE;
+        i_ret = add_item( p_access, p_node, psz_name, i_type );
         if( i_ret != VLC_SUCCESS )
             goto error;
     }
diff --git a/modules/access/dsm/sd.c b/modules/access/dsm/sd.c
index af4f50b..ab4ecec 100644
--- a/modules/access/dsm/sd.c
+++ b/modules/access/dsm/sd.c
@@ -120,8 +120,8 @@ static void netbios_ns_discover_on_entry_added( void *p_opaque,
         if( asprintf(&psz_mrl, "smb://%s", name) < 0 )
             return;
 
-        p_item = input_item_NewWithType( psz_mrl, name, 0, NULL,
-                                         0, -1, ITEM_TYPE_NODE );
+        p_item = input_item_NewWithTypeExt( psz_mrl, name, 0, NULL,
+                                            0, -1, ITEM_TYPE_NODE, 1 );
         msg_Dbg( p_sd, "Adding item %s", psz_mrl );
         free(psz_mrl);
 
-- 
2.1.3




More information about the vlc-devel mailing list