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.Error(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; playlist_format.FolderSeparator = MediaCapabilities.FolderSeparator; } SafeUri playlist_path = new SafeUri(System.IO.Path.Combine( PlaylistsWritePath, String.Format("{0}.{1}", escaped_name, PlaylistTypes[0].FileExtension))); System.IO.Stream stream = null; try { stream = Banshee.IO.File.OpenWrite(playlist_path, true); if (ms_device.RootPath == null) { playlist_format.BaseUri = new Uri(PlaylistsWritePath); } else { playlist_format.RootPath = ms_device.RootPath; playlist_format.BaseUri = new Uri(BaseDirectory); } playlist_format.Save(stream, from); } catch (Exception e) { Log.Error(e); } finally { stream.Close(); } } } }
public override void SyncPlaylists() { if (!CanSyncPlaylists) { return; } foreach (string file_name in PlaylistFiles) { Banshee.IO.File.Delete(new SafeUri(file_name)); } // 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; if (from != null) { 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}", from.Name, PlaylistTypes[0].FileExtension))); System.IO.Stream stream = Banshee.IO.File.OpenWrite(playlist_path, true); playlist_format.BaseUri = new Uri(BaseDirectory); playlist_format.Save(stream, from); stream.Close(); } } }