1 /*****************************************************************************
2 * directory.c : Use access readdir to output folder content to playlist
3 *****************************************************************************
4 * Copyright (C) 2014 VLC authors and VideoLAN
7 * Authors: Julien 'Lta' BALLET <contact # lta . io >
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_demux.h>
36 /*****************************************************************************
38 *****************************************************************************/
39 static int Demux( demux_t *p_demux );
42 int Import_Dir ( vlc_object_t *p_this)
44 demux_t *p_demux = (demux_t *)p_this;
46 bool b_is_dir = false;
47 int i_err = stream_Control( p_demux->s, STREAM_IS_DIRECTORY, &b_is_dir );
49 if ( !( i_err == VLC_SUCCESS && b_is_dir ) )
52 p_demux->pf_control = Control;
53 p_demux->pf_demux = Demux;
54 msg_Dbg( p_demux, "reading directory content" );
59 void Close_Dir ( vlc_object_t *p_this )
64 static int Demux( demux_t *p_demux )
66 input_item_t *p_input = GetCurrentItem(p_demux);
67 input_item_node_t *p_node = input_item_node_Create( p_input );
68 input_item_Release(p_input);
70 if( stream_ReadDir( p_demux->s, p_node ) )
72 input_item_node_Delete( p_node );
76 msg_Warn( p_demux, "unable to read directory" );
78 input_item_node_PostAndDelete( p_node );