From 8a1ca7778958645f470d5aefa82a9968eb511657 Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 2 Jan 2008 16:58:39 +0000 Subject: WinGui: - Chapters.csv and dvdinfo.dat are now saved in the windows temporary folder. This should mean the application doesn't need admin rights on Vista. Thanks to "doubt" for the patch. - Few UI theme tweaks. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1160 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/frmReadDVD.cs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'win/C#/frmReadDVD.cs') diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs index d6da8fe43..d7a074938 100644 --- a/win/C#/frmReadDVD.cs +++ b/win/C#/frmReadDVD.cs @@ -81,17 +81,31 @@ namespace Handbrake { try { - string appPath = Application.StartupPath.ToString() + "\\"; - string strCmdLine = "cmd /c " + '"' + '"' + appPath + "HandBrakeCLI.exe" + '"' + " -i " + '"' + inputFile + '"' + " -t0 -v >" + '"' + appPath + "dvdinfo.dat" + '"' + " 2>&1" + '"'; - Process hbproc = Process.Start("CMD.exe", strCmdLine); - hbproc.WaitForExit(); - hbproc.Dispose(); - hbproc.Close(); + string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe"); + string dvdInfoPath = Path.Combine(Path.GetTempPath(), "dvdinfo.dat"); + // Make we don't pick up a stale dvdinfo.dat (and that we have rights to the file) + if (File.Exists(dvdInfoPath)) + File.Delete(dvdInfoPath); - StreamReader sr = new StreamReader(appPath + "dvdinfo.dat"); - thisDvd = Parsing.DVD.Parse(sr); - sr.Close(); + string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 -v >""{2}"" 2>&1""", handbrakeCLIPath, inputFile, dvdInfoPath); + + using (Process hbproc = Process.Start("CMD.exe", strCmdLine)) + { + hbproc.WaitForExit(); + // TODO: Verify exit code if the CLI supports it properly + } + + + if (!File.Exists(dvdInfoPath)) + { + throw new Exception("Unable to retrieve the DVD Info. dvdinfo.dat missing."); + } + + using (StreamReader sr = new StreamReader(dvdInfoPath)) + { + thisDvd = Parsing.DVD.Parse(sr); + } updateUIElements(); } -- cgit v1.2.3