Browse Source

item: add created_item field in vlc_readdir_helper_additem function

In the access modules, we would like to be able to send file properties such as size directly
to the input item. But no reference to this item is accessible.
This field will allow you to retrieve the item created by the function.
pull/130/head
LE QUEC Nicolas 5 years ago
committed by Jean-Baptiste Kempf
parent
commit
97a09be754
  1. 6
      include/vlc_input_item.h
  2. 2
      modules/access/directory.c
  3. 2
      modules/access/dsm/access.c
  4. 2
      modules/access/ftp.c
  5. 4
      modules/access/nfs.c
  6. 2
      modules/access/samba.c
  7. 2
      modules/access/sftp.c
  8. 2
      modules/access/smb2.c
  9. 2
      modules/access/unc.c
  10. 2
      modules/stream_extractor/archive.c
  11. 10
      src/input/item.c

6
include/vlc_input_item.h

@ -592,10 +592,14 @@ VLC_API void vlc_readdir_helper_finish(struct vlc_readdir_helper *p_rdh, bool b_
* be valid.
* \param i_type see \ref input_item_type_e
* \param i_net see \ref input_item_net_type
* \param[out] created_item if an input item is created. The item should not be
* released and is valid until vlc_readdir_helper_finish() is called.
* \param status VLC_SUCCESS in case of success, an error otherwise. Parsing
* should be aborted in case of error.
*/
VLC_API int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
const char *psz_uri, const char *psz_flatpath,
const char *psz_filename,
int i_type, int i_net);
int i_type, int i_net, input_item_t **created_item);
#endif

2
modules/access/directory.c

@ -208,7 +208,7 @@ static int DirRead (stream_t *access, input_item_node_t *node)
break;
}
ret = vlc_readdir_helper_additem(&rdh, uri, NULL, entry, type,
ITEM_NET_UNKNOWN);
ITEM_NET_UNKNOWN, NULL);
free(uri);
}

2
modules/access/dsm/access.c

@ -594,7 +594,7 @@ static int add_item( stream_t *p_access, struct vlc_readdir_helper *p_rdh,
return VLC_ENOMEM;
i_ret = vlc_readdir_helper_additem( p_rdh, psz_uri, NULL, psz_name, i_type,
ITEM_NET );
ITEM_NET, NULL );
free( psz_uri );
return i_ret;
}

2
modules/access/ftp.c

@ -999,7 +999,7 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_current_node)
msg_Err(p_access, "%s -> %s", p_sys->url.psz_path, ms.ptr);
i_ret = vlc_readdir_helper_additem( &rdh, ms.ptr, NULL, psz_file,
type, ITEM_NET );
type, ITEM_NET, NULL );
free(ms.ptr);
}
free( psz_line );

4
modules/access/nfs.c

@ -364,7 +364,7 @@ DirRead(stream_t *p_access, input_item_node_t *p_node)
i_type = ITEM_TYPE_UNKNOWN;
}
i_ret = vlc_readdir_helper_additem(&rdh, psz_url, NULL, p_nfsdirent->name,
i_type, ITEM_NET);
i_type, ITEM_NET, NULL);
free(psz_url);
}
@ -394,7 +394,7 @@ MountRead(stream_t *p_access, input_item_node_t *p_node)
break;
}
i_ret = vlc_readdir_helper_additem(&rdh, psz_url, NULL, psz_name,
ITEM_TYPE_DIRECTORY, ITEM_NET);
ITEM_TYPE_DIRECTORY, ITEM_NET, NULL);
free(psz_url);
}

2
modules/access/samba.c

@ -171,7 +171,7 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_node )
}
free(psz_encoded_name);
i_ret = vlc_readdir_helper_additem(&rdh, uri, NULL, p_entry->name,
i_type, ITEM_NET);
i_type, ITEM_NET, NULL);
free(uri);
}

2
modules/access/sftp.c

@ -671,7 +671,7 @@ static int DirRead (stream_t *p_access, input_item_node_t *p_current_node)
int i_type = LIBSSH2_SFTP_S_ISDIR( attrs.permissions ) ? ITEM_TYPE_DIRECTORY : ITEM_TYPE_FILE;
i_ret = vlc_readdir_helper_additem( &rdh, psz_full_uri, NULL, psz_file,
i_type, ITEM_NET );
i_type, ITEM_NET, NULL );
free( psz_full_uri );
}

2
modules/access/smb2.c

@ -387,7 +387,7 @@ static int AddItem(stream_t *access, struct vlc_readdir_helper *rdh,
return VLC_ENOMEM;
int ret = vlc_readdir_helper_additem(rdh, url, NULL, name, i_type,
ITEM_NET);
ITEM_NET, NULL);
free(url);
return ret;
}

2
modules/access/unc.c

@ -212,7 +212,7 @@ static int DirRead(stream_t *p_access, input_item_node_t *p_node)
free( psz_path );
i_ret = vlc_readdir_helper_additem( &rdh, psz_uri, NULL,
psz_name, ITEM_TYPE_DIRECTORY, ITEM_NET );
psz_name, ITEM_TYPE_DIRECTORY, ITEM_NET, NULL );
free( psz_name );
free( psz_uri );
}

2
modules/stream_extractor/archive.c

@ -548,7 +548,7 @@ static int ReadDir( stream_directory_t* p_directory, input_item_node_t* p_node )
break;
if( vlc_readdir_helper_additem( &rdh, mrl, path, NULL, ITEM_TYPE_FILE,
ITEM_LOCAL ) )
ITEM_LOCAL, NULL ) )
{
free( mrl );
break;

10
src/input/item.c

@ -1823,7 +1823,8 @@ void vlc_readdir_helper_finish(struct vlc_readdir_helper *p_rdh, bool b_success)
int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
const char *psz_uri, const char *psz_flatpath,
const char *psz_filename, int i_type, int i_net)
const char *psz_filename, int i_type, int i_net,
input_item_t **restrict created_item)
{
enum slave_type i_slave_type;
struct rdh_slave *p_rdh_slave = NULL;
@ -1869,7 +1870,11 @@ int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
}
if (rdh_file_is_ignored(p_rdh, psz_filename))
{
if (created_item != NULL)
*created_item = NULL;
return VLC_SUCCESS;
}
input_item_node_t *p_node = p_rdh->p_node;
@ -1896,5 +1901,8 @@ int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
* slaves will be ignored by rdh_file_is_ignored() */
if (p_rdh_slave != NULL)
p_rdh_slave->p_node = p_node;
if (created_item != NULL)
*created_item = p_item;
return VLC_SUCCESS;
}

Loading…
Cancel
Save