It may be used under the terms of the GNU General Public License. */\r
\r
using System.IO;\r
+using System.Text;\r
using System.Text.RegularExpressions;\r
using System;\r
using System.Globalization;\r
/// <param name="TimeRemaining">The estimated time remaining for this task to complete</param>\r
public delegate void EncodeProgressEventHandler(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining);\r
\r
- \r
+\r
/// <summary>\r
/// A simple wrapper around a StreamReader to keep track of the entire output from a cli process\r
/// </summary>\r
internal class Parser : StreamReader\r
{\r
- private string m_buffer;\r
+ private StringBuilder _buffer = new StringBuilder("");\r
/// <summary>\r
/// The output from the CLI process\r
/// </summary>\r
- public string Buffer\r
+ public String Buffer\r
{\r
get\r
{\r
- return m_buffer;\r
+ return _buffer.ToString();\r
}\r
}\r
\r
/// Default constructor for this object\r
/// </summary>\r
/// <param name="baseStream">The stream to parse from</param>\r
- public Parser(Stream baseStream) : base(baseStream)\r
+ public Parser(Stream baseStream)\r
+ : base(baseStream)\r
{\r
- m_buffer = string.Empty;\r
}\r
\r
public override string ReadLine()\r
{\r
string tmp = base.ReadLine();\r
\r
- m_buffer += tmp;\r
- Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");\r
+ _buffer.Append(tmp + Environment.NewLine);\r
+\r
+ Match m = null;\r
+ if (tmp.Contains("Scanning title"))\r
+ m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");\r
+\r
if (OnReadLine != null)\r
OnReadLine(this, tmp);\r
\r
- if (m.Success && OnScanProgress != null)\r
- OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
+ if (m != null)\r
+ if (m.Success && OnScanProgress != null)\r
+ OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
\r
return tmp;\r
}\r
{\r
string tmp = base.ReadToEnd();\r
\r
- m_buffer += tmp;\r
+ _buffer.Append(tmp + Environment.NewLine);\r
+\r
if (OnReadToEnd != null)\r
OnReadToEnd(this, tmp);\r
\r