diff options
Diffstat (limited to 'win/C#/Functions')
-rw-r--r-- | win/C#/Functions/Encode.cs | 45 | ||||
-rw-r--r-- | win/C#/Functions/Main.cs | 3 |
2 files changed, 27 insertions, 21 deletions
diff --git a/win/C#/Functions/Encode.cs b/win/C#/Functions/Encode.cs index 6c30828c2..1579528a6 100644 --- a/win/C#/Functions/Encode.cs +++ b/win/C#/Functions/Encode.cs @@ -136,31 +136,38 @@ namespace Handbrake.Functions public void copyLog(string destination)
{
// The user may wish to do something with the log.
- if (Properties.Settings.Default.saveLog == "Checked")
+ if (Properties.Settings.Default.saveLogToSpecifiedPath == "Checked")
{
- string logPath = Path.Combine(Path.GetTempPath(), "hb_encode_log.dat");
-
- if (Properties.Settings.Default.saveLogWithVideo == "Checked")
+ try
{
- string[] destName = destination.Split('\\');
- string destinationFile = "";
- for (int i = 0; i < destName.Length - 1; i++)
- {
- destinationFile += destName[i] + "\\";
- }
+ string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
+ string tempLogFile = Path.Combine(Path.GetTempPath(), "hb_encode_log.dat");
- destinationFile += DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destName[destName.Length - 1] + ".txt";
+ string encodeDestinationPath = Path.GetDirectoryName(destination);
+ String[] destName = destination.Split('\\');
+ string destinationFile = destName[destName.Length - 1];
+ string encodeLogFile = DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destinationFile + ".txt";
- File.Copy(logPath, destinationFile);
+ // Make sure the log directory exists.
+ if (!Directory.Exists(logDir))
+ Directory.CreateDirectory(logDir);
+
+ // Copy the Log to HandBrakes log folder in the users applciation data folder.
+ File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));
+
+ // Save a copy of the log file in the same location as the enocde.
+ if (Properties.Settings.Default.saveLogWithVideo == "Checked")
+ File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));
+
+ // Save a copy of the log file to a user specified location
+ if (Directory.Exists(Properties.Settings.Default.saveLogPath))
+ if (Properties.Settings.Default.saveLogPath != String.Empty && Properties.Settings.Default.saveLogToSpecifiedPath == "Checked")
+ File.Copy(tempLogFile, Path.Combine(Properties.Settings.Default.saveLogPath, encodeLogFile));
}
- else if (Properties.Settings.Default.saveLogPath != String.Empty)
+ catch (Exception exc)
{
- string[] destName = destination.Split('\\');
- string dest = destName[destName.Length - 1];
- string filename = DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + dest + ".txt";
- string useDefinedLogPath = Path.Combine(Properties.Settings.Default.saveLogPath, filename);
-
- File.Copy(logPath, useDefinedLogPath);
+ MessageBox.Show("Something went a bit wrong trying to copy your log file.\nError Information:\n\n" + exc, "Error",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 6c432208a..d7161205f 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -296,14 +296,13 @@ namespace Handbrake.Functions try
{
cliProcess.Start();
- cliProcess.Kill();
// Retrieve standard output and report back to parent thread until the process is complete
TextReader stdOutput = cliProcess.StandardError;
while (!cliProcess.HasExited)
{
line = stdOutput.ReadLine() ?? "";
- Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");
+ Match m = Regex.Match(line, @"HandBrake ([0-9.]*)(svn[0-9M]*) \([0-9]*\)");
if (m.Success)
{
|