*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
add_string( "recursive", "expand" , NULL, RECURSIVE_TEXT,
RECURSIVE_LONGTEXT, VLC_FALSE );
change_string_list( psz_recursive_list, psz_recursive_list_text, 0 );
-#ifdef HAVE_STRSEP
add_string( "ignore-filetypes", "m3u,db,nfo,jpg,gif,sfv,txt,sub,idx,srt,cue",
NULL, IGNORE_TEXT, IGNORE_LONGTEXT, VLC_FALSE );
-#endif
set_callbacks( Open, Close );
add_submodule();
static int DemuxControl( demux_t *p_demux, int i_query, va_list args );
-static int ReadDir( playlist_t *, char *psz_name, int i_mode, int *pi_pos,
+static int ReadDir( playlist_t *, const char *psz_name, int i_mode,
playlist_item_t * );
/*****************************************************************************
}
p_item->input.i_type = ITEM_TYPE_DIRECTORY;
- if( ReadDir( p_playlist, psz_name , i_mode, &i_pos,
- p_item ) != VLC_SUCCESS )
+ if( ReadDir( p_playlist, psz_name , i_mode, p_item ) != VLC_SUCCESS )
{
}
end:
{
return 0;
}
+
/*****************************************************************************
* DemuxControl:
*****************************************************************************/
{
return VLC_TRUE;
}
+
/*****************************************************************************
* ReadDir: read a directory and add its content to the list
*****************************************************************************/
-static int ReadDir( playlist_t *p_playlist,
- char *psz_name, int i_mode, int *pi_position,
- playlist_item_t *p_parent )
+static int ReadDir( playlist_t *p_playlist, const char *psz_name,
+ int i_mode, playlist_item_t *p_parent )
{
struct dirent **pp_dir_content;
int i_dir_content, i;
{
int b;
char *tmp;
-
+
while( psz_parser[0] != '\0' && psz_parser[0] == ' ' ) psz_parser++;
for( b = 0; psz_parser[b] != '\0'; b++ )
{
if( 0 )
#endif
{
+#if defined( S_ISLNK )
+/*
+ * FIXME: there is a ToCToU race condition here; but it is rather tricky
+ * impossible to fix while keeping some kind of portable code, and maybe even
+ * in a non-portable way.
+ */
+ if( lstat( psz_uri, &stat_data )
+ || S_ISLNK(stat_data.st_mode) )
+ {
+ msg_Dbg( p_playlist, "Skipping directory symlink %s",
+ psz_uri );
+ free( psz_uri );
+ continue;
+ }
+#endif
if( i_mode == MODE_NONE )
{
msg_Dbg( p_playlist, "Skipping subdirectory %s", psz_uri );
p_node->input.i_type = ITEM_TYPE_DIRECTORY;
if( ReadDir( p_playlist, psz_uri , MODE_EXPAND,
- pi_position, p_node ) != VLC_SUCCESS )
+ p_node ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
playlist_NodeAddItem( p_playlist,p_item,
p_parent->pp_parents[0]->i_view,
p_parent,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND | PLAYLIST_PREPARSE,
+ PLAYLIST_END );
playlist_CopyParents( p_parent, p_item );
}
if( ppsz_extensions ) free( ppsz_extensions );
if( psz_ignore ) free( psz_ignore );
- free( pp_dir_content );
+ for( i = 0; i < i_dir_content; i++ )
+ if( pp_dir_content[i] ) free( pp_dir_content[i] );
+ if( pp_dir_content ) free( pp_dir_content );
return VLC_SUCCESS;
}