[vlc-devel] [PATCH] dsm: mark directories in readdir
Thomas Guillem
thomas at gllm.fr
Wed Mar 18 10:20:28 CET 2015
Hi Petri,
I already proposed some patches to know if an item is a directory (or
browsable in my case)
see
https://mailman.videolan.org/pipermail/vlc-devel/2015-February/101211.html
and
https://mailman.videolan.org/pipermail/vlc-devel/2015-February/101212.html
But I'm not sure which one is the best solution.
The ITEM_TYPE_* seems to be used mainly for UI (from Qt). Third party
applications using libvlc for browsing files/smb/sftp/upnp will need to
know if an item is a directory or is browsable.
The problem using ITEM_TYPE_ is that an item can be a net and a
directory. Which one do you choose ? Maybe we should use a bitmask and
have i_type = ITEM_TYPE_NET|ITEM_TYPE_DIRECTORY.
An other issue with your patch is that the preparser will preparses all
items that are directory. Therefore all children directories will be
preparsed recursively and we don't want that. Indeed we want to parse
only when clicking on the item from the playlist/browser.
I'm still thinking about the proper way to have a valid
item_type/item_browsable and have the preparser not preparsing all the
children recursively.
On Wed, Mar 18, 2015, at 09:21, Petri Hintukainen wrote:
> From: Petri Hintukainen <phintuka at gmail.com>
>
> ---
> modules/access/dsm/access.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
> index 6e30adc..ab03493 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,7 @@ 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_NewWithType( psz_uri, psz_name, 0, NULL, 0, -1,
> i_type );
> free( psz_uri );
> if( p_item == NULL )
> return VLC_ENOMEM;
> @@ -623,7 +623,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_UNKNOWN
> );
> if( i_ret != VLC_SUCCESS )
> goto error;
> }
> @@ -644,6 +644,7 @@ static int BrowseDirectory( access_t *p_access,
> input_item_node_t *p_node )
> const char *psz_name;
> size_t files_count;
> int i_ret;
> + int i_type;
>
> if( p_sys->psz_path != NULL )
> {
> @@ -675,7 +676,9 @@ static int BrowseDirectory( access_t *p_access,
> input_item_node_t *p_node )
> 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_UNKNOWN;
> +
> + i_ret = add_item( p_access, p_node, psz_name, i_type );
> if( i_ret != VLC_SUCCESS )
> goto error;
> }
> --
> 2.1.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list