Commit 34174cd2 authored by Francois Cartegnie's avatar Francois Cartegnie

playlist: indirectly write when exporting to ml.xspf

parent e7847d8d
...@@ -182,19 +182,19 @@ int playlist_MLLoad( playlist_t *p_playlist ) ...@@ -182,19 +182,19 @@ int playlist_MLLoad( playlist_t *p_playlist )
int playlist_MLDump( playlist_t *p_playlist ) int playlist_MLDump( playlist_t *p_playlist )
{ {
char *psz_datadir; char *psz_temp;
psz_datadir = config_GetUserDir( VLC_DATA_DIR ); psz_temp = config_GetUserDir( VLC_DATA_DIR );
if( !psz_datadir ) /* XXX: This should never happen */ if( !psz_temp ) /* XXX: This should never happen */
{ {
msg_Err( p_playlist, "no data directory, cannot save media library") ; msg_Err( p_playlist, "no data directory, cannot save media library") ;
return VLC_EGENERIC; return VLC_EGENERIC;
} }
char psz_dirname[ strlen( psz_datadir ) + sizeof( DIR_SEP "ml.xspf")]; char psz_dirname[ strlen( psz_temp ) + sizeof( DIR_SEP "ml.xspf")];
strcpy( psz_dirname, psz_datadir ); strcpy( psz_dirname, psz_temp );
free( psz_datadir ); free( psz_temp );
if( config_CreateDir( (vlc_object_t *)p_playlist, psz_dirname ) ) if( config_CreateDir( (vlc_object_t *)p_playlist, psz_dirname ) )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -202,8 +202,25 @@ int playlist_MLDump( playlist_t *p_playlist ) ...@@ -202,8 +202,25 @@ int playlist_MLDump( playlist_t *p_playlist )
strcat( psz_dirname, DIR_SEP "ml.xspf" ); strcat( psz_dirname, DIR_SEP "ml.xspf" );
playlist_Export( p_playlist, psz_dirname, p_playlist->p_media_library, if ( asprintf( &psz_temp, "%s.tmp", psz_dirname ) < 1 )
return VLC_EGENERIC;
int i_ret = playlist_Export( p_playlist, psz_temp, p_playlist->p_media_library,
"export-xspf" ); "export-xspf" );
if ( i_ret != VLC_SUCCESS )
{
vlc_unlink( psz_temp );
free( psz_temp );
return i_ret;
}
i_ret = vlc_rename( psz_temp, psz_dirname );
free( psz_temp );
if( i_ret == -1 )
{
msg_Err( p_playlist, "could not rename %s.tmp: %s",
psz_dirname, vlc_strerror_c(errno) );
return VLC_EGENERIC;
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment