public override void SyncPlaylists ()
{
if (!CanSyncPlaylists) {
return;
}
foreach (string file_name in PlaylistFiles) {
try {
Banshee.IO.File.Delete (new SafeUri (file_name));
} catch (Exception e) {
Log.Exception (e);
}
}
// Add playlists from Banshee to the device
PlaylistFormatBase playlist_format = null;
List<Source> children = new List<Source> (Children);
foreach (Source child in children) {
PlaylistSource from = child as PlaylistSource;
string escaped_name = StringUtil.EscapeFilename (child.Name);
if (from != null && !String.IsNullOrEmpty (escaped_name)) {
from.Reload ();
if (playlist_format == null) {
playlist_format = Activator.CreateInstance (PlaylistTypes[0].Type) as PlaylistFormatBase;
}
SafeUri playlist_path = new SafeUri (System.IO.Path.Combine (
PlaylistsPath, String.Format ("{0}.{1}", escaped_name, PlaylistTypes[0].FileExtension)));
System.IO.Stream stream = null;
try {
stream = Banshee.IO.File.OpenWrite (playlist_path, true);
playlist_format.BaseUri = new Uri (PlaylistsPath);
playlist_format.Save (stream, from);
} catch (Exception e) {
Log.Exception (e);
} finally {
stream.Close ();
}
}
}
}