*****************************************************************************/
#include <vlc/vlc.h>
-#include <vlc/input.h>
#include <vlc_playlist.h>
#include <vlc_input.h>
+#include <vlc_access.h>
+#include <vlc_demux.h>
#include <stdlib.h>
#include <string.h>
# include <dirent.h>
#endif
-#include "charset.h"
+#include <vlc_charset.h>
/*****************************************************************************
* Module descriptor
static int ReadDir( playlist_t *, const char *psz_name, int i_mode,
- playlist_item_t *, playlist_item_t * );
+ playlist_item_t *, playlist_item_t *, input_item_t * );
/*****************************************************************************
* Open: open the directory
*****************************************************************************/
static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
{
- char *psz;
- int i_mode, i_activity;
-
- char *psz_name = strdup (p_access->psz_path);
- if (psz_name == NULL)
+ char *psz;
+ int i_mode, i_activity;
+ playlist_t *p_playlist = pl_Yield( p_access );
+ playlist_item_t *p_item_in_category;
+ input_item_t *p_current_input = input_GetItem(
+ (input_thread_t*)p_access->p_parent);
+ playlist_item_t *p_current = playlist_ItemGetByInput( p_playlist,
+ p_current_input,
+ VLC_FALSE );
+ char *psz_name = strdup (p_access->psz_path);
+
+ if( psz_name == NULL )
return VLC_ENOMEM;
+ if( p_current == NULL ) {
+ msg_Err( p_access, "unable to find item in playlist" );
+ return VLC_ENOOBJ;
+ }
+
/* Remove the ending '/' char */
if (psz_name[0])
{
}
}
- playlist_item_t *p_item, *p_root_category;
- playlist_t *p_playlist = pl_Yield( p_access );
-
/* Handle mode */
psz = var_CreateGetString( p_access, "recursive" );
if( *psz == '\0' || !strncmp( psz, "none" , 4 ) )
msg_Dbg( p_access, "opening directory `%s'", p_access->psz_path );
- if( p_playlist->status.p_item && p_playlist->status.p_item->p_input ==
- ((input_thread_t *)p_access->p_parent)->input.p_item )
- p_item = p_playlist->status.p_item;
- else
- {
- input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)->
- input.p_item;
- p_item = playlist_LockItemGetByInput( p_playlist, p_current );
- if( !p_item )
- {
- msg_Dbg( p_playlist, "unable to find item in playlist");
- return VLC_ENOOBJ;
- }
- }
- p_item->p_input->i_type = ITEM_TYPE_DIRECTORY;
-
- p_root_category = playlist_LockItemToNode( p_playlist, p_item );
+ p_current->p_input->i_type = ITEM_TYPE_DIRECTORY;
+ p_item_in_category = playlist_ItemToNode( p_playlist, p_current,
+ VLC_FALSE );
i_activity = var_GetInteger( p_playlist, "activity" );
var_SetInteger( p_playlist, "activity", i_activity +
DIRECTORY_ACTIVITY );
- ReadDir( p_playlist, psz_name, i_mode, p_item, p_root_category );
+ ReadDir( p_playlist, psz_name, i_mode, p_current, p_item_in_category,
+ p_current_input );
i_activity = var_GetInteger( p_playlist, "activity" );
var_SetInteger( p_playlist, "activity", i_activity -
DIRECTORY_ACTIVITY );
+
+ playlist_Signal( p_playlist );
+
if( psz_name ) free( psz_name );
vlc_object_release( p_playlist );
*****************************************************************************/
static int ReadDir( playlist_t *p_playlist, const char *psz_name,
int i_mode, playlist_item_t *p_parent,
- playlist_item_t *p_parent_category )
+ playlist_item_t *p_parent_category,
+ input_item_t *p_current_input )
{
char **pp_dir_content = NULL;
int i_dir_content, i, i_return = VLC_SUCCESS;
{
const char *entry = pp_dir_content[i];
int i_size_entry = strlen( psz_name ) +
- strlen( entry ) + 2;
+ strlen( entry ) + 2 + 7 /* strlen("file://") */;
char psz_uri[i_size_entry];
sprintf( psz_uri, "%s/%s", psz_name, entry);
{
msg_Dbg(p_playlist, "creading subdirectory %s", psz_uri );
- p_node = playlist_NodeCreate (p_playlist, entry,
- p_parent_category);
+ p_node = playlist_NodeCreate( p_playlist, entry,
+ p_parent_category,
+ PLAYLIST_NO_REBUILD );
/* If we had the parent in category, the it is now node.
* Else, we still don't have */
if( ReadDir( p_playlist, psz_uri , MODE_EXPAND,
- p_node, p_parent_category ? p_node : NULL )
+ p_node, p_parent_category ? p_node : NULL,
+ p_current_input )
!= VLC_SUCCESS )
{
i_return = VLC_EGENERIC;
}
}
+ memmove (psz_uri + 7, psz_uri, sizeof (psz_uri) - 7);
+ memcpy (psz_uri, "file://", 7);
p_input = input_ItemNewWithType( VLC_OBJECT(p_playlist),
psz_uri, entry, 0, NULL,
-1, ITEM_TYPE_VFILE );
if (p_input != NULL)
- playlist_AddWhereverNeeded (p_playlist, p_input, p_parent,
- p_parent_category, VLC_FALSE,
- PLAYLIST_APPEND|PLAYLIST_PREPARSE);
+ {
+ if( p_current_input )
+ input_ItemCopyOptions( p_current_input, p_input );
+ playlist_BothAddInput( p_playlist, p_input,
+ p_parent_category,
+ PLAYLIST_APPEND|PLAYLIST_PREPARSE|
+ PLAYLIST_NO_REBUILD,
+ PLAYLIST_END, NULL, NULL );
+ }
}
}
}