#include <vlc_events.h>
#include "playlist_internal.h"
#include "config/configuration.h"
-#include <vlc_charset.h>
+#include <vlc_fs.h>
#include <vlc_url.h>
+#include <vlc_modules.h>
#include <sys/types.h>
#include <sys/stat.h>
/* Prepare the playlist_export_t structure */
p_export->p_root = p_export_root;
p_export->psz_filename = psz_filename;
- p_export->p_file = utf8_fopen( psz_filename, "wt" );
+ p_export->p_file = vlc_fopen( psz_filename, "wt" );
if( p_export->p_file == NULL )
msg_Err( p_export, "could not create playlist file %s (%m)",
psz_filename );
{
input_item_t *p_input;
const char *const psz_option = "meta-file";
- char *psz_uri = make_URI( psz_file );
+ char *psz_uri = make_URI( psz_file, NULL );
if( psz_uri == NULL )
return VLC_EGENERIC;
PL_LOCK;
playlist_InsertInputItemTree ( p_playlist, p_playlist->p_media_library,
- p_root, 0, !pl_priv(p_playlist)->b_tree );
+ p_root, 0, false );
PL_UNLOCK;
}
int playlist_MLLoad( playlist_t *p_playlist )
{
- char *psz_datadir;
- char *psz_uri = NULL;
input_item_t *p_input;
- psz_datadir = config_GetUserDir( VLC_DATA_DIR );
-
+ char *psz_datadir = config_GetUserDir( VLC_DATA_DIR );
if( !psz_datadir ) /* XXX: This should never happen */
{
msg_Err( p_playlist, "no data directory, cannot load media library") ;
return VLC_EGENERIC;
}
- if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xspf", psz_datadir ) != -1 )
- { /* loosy check for media library file */
- struct stat st;
- int ret = utf8_stat( psz_uri , &st );
- free( psz_uri );
- if( ret )
- {
- free( psz_datadir );
- return VLC_EGENERIC;
- }
- }
-
- psz_uri = make_URI( psz_datadir );
+ char *psz_file;
+ if( asprintf( &psz_file, "%s" DIR_SEP "ml.xspf", psz_datadir ) == -1 )
+ psz_file = NULL;
free( psz_datadir );
- psz_datadir = psz_uri;
- if( psz_datadir == NULL )
+ if( psz_file == NULL )
+ return VLC_ENOMEM;
+
+ /* loosy check for media library file */
+ struct stat st;
+ if( vlc_stat( psz_file, &st ) )
+ {
+ free( psz_file );
return VLC_EGENERIC;
+ }
- /* Force XSPF demux (psz_datadir was a path, now it is a file URI) */
- if( asprintf( &psz_uri, "file/xspf-open%s/ml.xspf", psz_datadir+4 ) == -1 )
- psz_uri = NULL;
- free( psz_datadir );
- psz_datadir = NULL;
+ char *psz_uri = make_URI( psz_file, "file/xspf-open" );
+ free( psz_file );
if( psz_uri == NULL )
return VLC_ENOMEM;