using System.Diagnostics;\r
using System.IO;\r
using System.Linq;\r
+ using System.Security.Cryptography;\r
using System.Text;\r
using System.Text.RegularExpressions;\r
using System.Windows.Forms;\r
// Add the appropriate file extension\r
if (mainWindow.drop_format.SelectedIndex == 0)\r
{\r
- destinationFilename += Properties.Settings.Default.useM4v || mainWindow.Check_ChapterMarkers.Checked ||\r
+ destinationFilename += Properties.Settings.Default.useM4v == 0 || Properties.Settings.Default.useM4v == 2 || mainWindow.Check_ChapterMarkers.Checked ||\r
mainWindow.AudioSettings.RequiresM4V() || mainWindow.Subtitles.RequiresM4V()\r
? ".m4v"\r
: ".mp4";\r
\r
// 0 = SVN Build / Version\r
// 1 = Build Date\r
- DateTime lastModified = File.GetLastWriteTime("HandBrakeCLI.exe");\r
\r
- if (Properties.Settings.Default.hb_build != 0 && Properties.Settings.Default.cliLastModified == lastModified)\r
+ // Get the SHA1 Hash of HandBrakeCLI\r
+ byte[] hash;\r
+ using (Stream stream = File.OpenRead(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe")))\r
+ {\r
+ hash = SHA1.Create().ComputeHash(stream);\r
+ }\r
+ string base64Hash = Convert.ToBase64String(hash);\r
+ \r
+ // Compare the hash with the last known hash. If it's the same, return.\r
+ if (Properties.Settings.Default.CliExeHash == base64Hash)\r
{\r
return;\r
}\r
\r
- Properties.Settings.Default.cliLastModified = lastModified;\r
-\r
+ // It's not the same, so start the CLI to get it's version data.\r
Process cliProcess = new Process();\r
ProcessStartInfo handBrakeCli = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")\r
{\r
}\r
}\r
\r
+ Properties.Settings.Default.CliExeHash = base64Hash;\r
+\r
Properties.Settings.Default.Save();\r
}\r
catch (Exception e)\r
{\r
Properties.Settings.Default.hb_build = 0;\r
+ Properties.Settings.Default.CliExeHash = null;\r
Properties.Settings.Default.Save();\r
\r
ShowExceptiowWindow("Unable to retrieve version information from the CLI.", e.ToString());\r
/// <param name="encodeQueue">\r
/// The encode Queue.\r
/// </param>\r
- public static void RecoverQueue(IQueue encodeQueue)\r
+ public static void RecoverQueue(IQueueProcessor encodeQueue)\r
{\r
+ string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+\r
DialogResult result = DialogResult.None;\r
List<string> queueFiles = CheckQueueRecovery();\r
if (queueFiles.Count == 1)\r
{\r
foreach (string file in queueFiles)\r
{\r
- encodeQueue.LoadQueueFromFile(file); // Start Recovery\r
+ encodeQueue.QueueManager.RestoreQueue(appDataPath + file); // Start Recovery\r
}\r
}\r
else\r
{\r
if (IsMultiInstance) return; // Don't tamper with the files if we are multi instance\r
\r
- string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
foreach (string file in queueFiles)\r
{\r
- if (File.Exists(Path.Combine(tempPath, file)))\r
- File.Delete(Path.Combine(tempPath, file));\r
+ if (File.Exists(Path.Combine(appDataPath, file)))\r
+ File.Delete(Path.Combine(appDataPath, file));\r
}\r
}\r
}\r
}\r
\r
/// <summary>\r
- /// Clear all the encode log files.\r
- /// </summary>\r
- public static void ClearLogs()\r
- {\r
- string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
- if (Directory.Exists(logDir))\r
- {\r
- DirectoryInfo info = new DirectoryInfo(logDir);\r
- FileInfo[] logFiles = info.GetFiles("*.txt");\r
- foreach (FileInfo file in logFiles)\r
- {\r
- if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log"))\r
- File.Delete(file.FullName);\r
- }\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Clear old log files x days in the past\r
- /// </summary>\r
- public static void ClearOldLogs()\r
- {\r
- string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
- if (Directory.Exists(logDir))\r
- {\r
- DirectoryInfo info = new DirectoryInfo(logDir);\r
- FileInfo[] logFiles = info.GetFiles("*.txt");\r
-\r
- foreach (FileInfo file in logFiles)\r
- {\r
- if (file.LastWriteTime < DateTime.Now.AddDays(-30))\r
- {\r
- if (!file.Name.Contains("last_scan_log.txt") && !file.Name.Contains("last_encode_log.txt"))\r
- File.Delete(file.FullName);\r
- }\r
- }\r
- }\r
- }\r
-\r
- /// <summary>\r
/// Map languages and their iso639_2 value into a IDictionary\r
/// </summary>\r
/// <returns>A Dictionary containing the language and iso code</returns>\r
}\r
\r
/// <summary>\r
- /// Get a list of available DVD drives which are ready and contain DVD content.\r
- /// </summary>\r
- /// <returns>A List of Drives with their details</returns>\r
- public static List<DriveInformation> GetDrives()\r
- {\r
- List<DriveInformation> drives = new List<DriveInformation>();\r
- DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();\r
- int id = 0;\r
- foreach (DriveInfo curDrive in theCollectionOfDrives)\r
- {\r
- if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady &&\r
- File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))\r
- {\r
- drives.Add(new DriveInformation\r
- {\r
- Id = id,\r
- VolumeLabel = curDrive.VolumeLabel,\r
- RootDirectory = curDrive.RootDirectory + "VIDEO_TS"\r
- });\r
- id++;\r
- }\r
- }\r
- return drives;\r
- }\r
-\r
- /// <summary>\r
/// Change a string to Title Case/\r
/// </summary>\r
/// <param name="input">\r