[vlc-commits] se/archive: use readdir_helper
Thomas Guillem
git at videolan.org
Wed Sep 20 17:38:46 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Sep 20 10:39:35 2017 +0200| [a913906b1327e3a4705c8e85d9989222bf5f7e1a] | committer: Thomas Guillem
se/archive: use readdir_helper
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a913906b1327e3a4705c8e85d9989222bf5f7e1a
---
modules/stream_extractor/archive.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/modules/stream_extractor/archive.c b/modules/stream_extractor/archive.c
index b2bf4f9d47..9796d0b7bd 100644
--- a/modules/stream_extractor/archive.c
+++ b/modules/stream_extractor/archive.c
@@ -505,6 +505,8 @@ static int ReadDir( stream_directory_t* p_directory, input_item_node_t* p_node )
private_sys_t* p_sys = p_directory->p_sys;
libarchive_t* p_arc = p_sys->p_archive;
+ struct vlc_readdir_helper rdh;
+ vlc_readdir_helper_init( &rdh, p_directory, p_node);
struct archive_entry* entry;
int archive_status;
@@ -517,28 +519,22 @@ static int ReadDir( stream_directory_t* p_directory, input_item_node_t* p_node )
char* mrl = vlc_stream_extractor_CreateMRL( p_directory, path );
if( unlikely( !mrl ) )
- return VLC_ENOMEM;
-
- input_item_t* p_item = input_item_New( mrl, path );
+ break;
+ if( vlc_readdir_helper_additem( &rdh, mrl, path, NULL, ITEM_TYPE_FILE,
+ ITEM_LOCAL ) )
+ {
+ free( mrl );
+ break;
+ }
free( mrl );
- if( unlikely( !p_item ) )
- return VLC_ENOMEM;
-
-
- input_item_CopyOptions( p_node->p_item, p_item );
- input_item_node_AppendItem( p_node, p_item );
- input_item_Release( p_item );
-
if( archive_read_data_skip( p_arc ) )
break;
}
- if( archive_status != ARCHIVE_EOF )
- return VLC_EGENERIC;
-
- return VLC_SUCCESS;
+ vlc_readdir_helper_finish( &rdh, archive_status == ARCHIVE_EOF );
+ return archive_status == ARCHIVE_EOF ? VLC_SUCCESS : VLC_EGENERIC;
}
static ssize_t Read( stream_extractor_t *p_extractor, void* p_data, size_t i_size )
More information about the vlc-commits
mailing list