mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-03-06 12:10:42 +01:00
- targeting .NET 4.0 and DevExpress 13.1
- auto-detect byte-order for Panasonic "svl.bin" channel list - saving SamToolBox *.chl channel list - no longer auto-saving *.csv channel list - disabled, incomplete: creating channels from reference list
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ChanSort.Api
|
||||
{
|
||||
@@ -11,7 +12,7 @@ namespace ChanSort.Api
|
||||
public class ChlFileSerializer
|
||||
{
|
||||
private static readonly char[] Separators = new[] { ';' };
|
||||
private readonly System.Text.StringBuilder warnings = new System.Text.StringBuilder();
|
||||
private readonly StringBuilder warnings = new StringBuilder();
|
||||
private int lineNumber;
|
||||
private DataRoot dataRoot;
|
||||
private ChannelList channelList;
|
||||
@@ -30,7 +31,7 @@ namespace ChanSort.Api
|
||||
foreach (var channel in this.channelList.Channels)
|
||||
channel.NewProgramNr = -1;
|
||||
|
||||
using (var stream = new StreamReader(fileName, System.Text.Encoding.Default))
|
||||
using (var stream = new StreamReader(fileName, Encoding.Default))
|
||||
{
|
||||
ReadChannelsFromStream(stream);
|
||||
}
|
||||
@@ -97,5 +98,23 @@ namespace ChanSort.Api
|
||||
this.warnings.AppendFormat("Line {0,4}: Pr# {1,4}, channel '{2}' found multiple times\r\n", this.lineNumber, progNr, name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Save()
|
||||
public void Save(string fileName, ChannelList list)
|
||||
{
|
||||
using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
|
||||
{
|
||||
foreach (var channel in list.Channels.OrderBy(c => c.NewProgramNr))
|
||||
{
|
||||
if (channel.NewProgramNr == -1) continue;
|
||||
|
||||
writer.Write(channel.NewProgramNr);
|
||||
writer.Write(';');
|
||||
writer.Write(channel.Name);
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user