Skip to content

Commit

Permalink
Added some README sections about PATH's and updated PATH detection
Browse files Browse the repository at this point in the history
  • Loading branch information
hilts-vaughan committed Apr 30, 2015
1 parent 3c04688 commit 444093d
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 19 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ Following the below directions for getting the depedencies you might need:

**.NET**: You should already have this.

You'll need to add the MKVToolnix to your PATH as well. To do this:
If you get issues with "MKVToolnix" not found, you'll need to add the MKVToolnix to your PATH as well. The application will try and out detect it and will succeed if you use the above installer version.

Otherwise, do this:

Select Computer from the Start menu (or hold Windows key and press Break), choose "Advanced System Settings", then the Advanced tab. Click on Environment Variables. Under System Variables, find PATH, and click on it. In the Edit window, modify PATH by adding a semicolon ";" at the end and then the path to your MKVtoolnix installation, e.g. C:\Program Files (x86)\MKVToolNix (wherever you installed it to, this should be different for different drive letters or 64 bit)

Expand Down Expand Up @@ -75,6 +76,7 @@ After installing all the depedencies, just run the application.

The check boxes should be left unchecked for the most part unless you have a particular issue with a release. You can play around with them and file a bug report if a certain MKV file is not working.


# I found a bug/the application doesn't Unlink my MKV's properly. Help?

You can post the issue with a verbose log on the issue tracker. Tick the "verbose output" checkbox in the options when doing the run before posting a log on the issue tracked. If the issue is part of the UnlinkMKV core, it will be addressed there. Otherwise, it will be addressed here.
Expand Down
52 changes: 38 additions & 14 deletions UnlinkMKV-GUI/UnlinkMKV-GUI/FormApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class FormApplication : Form
public FormApplication()
{
InitializeComponent();

textOutput.Text = Properties.Settings.Default["output"].ToString();
textInput.Text = Properties.Settings.Default["input"].ToString();

Expand All @@ -34,7 +34,7 @@ public FormApplication()
Directory.CreateDirectory(defaultPath);
textOutput.Text = defaultPath;
}

// Create our options
CreateOptions();
}
Expand All @@ -45,8 +45,23 @@ private void CreateOptions()

var optionList = new List<Tuple<string, string>>();

optionList.Add(Tuple.Create("Fix audio", "--fix-audio"));
optionList.Add(Tuple.Create("Fix video", "--fix-video"));
bool foundMpeg = true;

try
{
PathUtility.FindExePath("ffmpeg.exe");
}
catch (FileNotFoundException exception)
{
foundMpeg = false;
}

if (foundMpeg)
{
optionList.Add(Tuple.Create("Fix audio", "--fix-audio"));
optionList.Add(Tuple.Create("Fix video", "--fix-video"));
}

optionList.Add(Tuple.Create("Fix subtitles", "--fix-subtitles"));
optionList.Add(Tuple.Create("Ignore default flag", "--ignore-default-flag"));
optionList.Add(Tuple.Create("Ignore missing segments", "--ignore-missing-segments"));
Expand Down Expand Up @@ -184,17 +199,26 @@ private void PerformJob()
var quotedFile = "\"" + file + "\"";
var argument = "\"" + perlScript + "\" " + perlParams + " " + outDirectory + " " + quotedFile;

var perlJob = new Process
// PathUtility.ExceptionalPath
var startInfo = new ProcessStartInfo
{
FileName = perlPath,
Arguments = argument,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};

// Add the path if required to the Perl executing path
if (!string.IsNullOrEmpty(PathUtility.ExceptionalPath))
{
startInfo.EnvironmentVariables["PATH"] = PathUtility.ExceptionalPath;
}

var perlJob = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = perlPath,
Arguments = argument,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
StartInfo = startInfo
};


Expand Down
2 changes: 1 addition & 1 deletion UnlinkMKV-GUI/UnlinkMKV-GUI/FormValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public FormValidator()
private void CheckRequirements()
{
var validatorTasks = new List<IValidatorTask>();
validatorTasks.Add(new MkvToolNixValidatorTask());
validatorTasks.Add(new IsAdministratorValidatorTask());
validatorTasks.Add(new MkvToolNixValidatorTask());;
validatorTasks.Add(new PerlExistsValidatorTask());

foreach (var task in validatorTasks)
Expand Down
5 changes: 5 additions & 0 deletions UnlinkMKV-GUI/UnlinkMKV-GUI/PathUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace UnlinkMKV_GUI
{
public static class PathUtility
{


public static string ExceptionalPath = "";


// Thanks!
// http://csharptest.net/526/how-to-search-the-environments-path-for-an-exe-or-dll/

Expand Down
50 changes: 47 additions & 3 deletions UnlinkMKV-GUI/UnlinkMKV-GUI/Valdiators/Validators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ public string GetStatusText()

public bool IsRequirementMet()
{

// Check for the path's to the tools we required
try
{

PathUtility.FindExePath("mkvextract.exe");
PathUtility.FindExePath("mkvinfo.exe");
PathUtility.FindExePath("mkvmerge.exe");
PathUtility.FindExePath("ffmpeg.exe");
}
catch (FileNotFoundException exception)
{
Expand All @@ -38,6 +37,51 @@ public bool IsRequirementMet()

public bool AttemptFixRequirement()
{
int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 6) || (p == 128))
{
return false;
}


// Attempt to find them in the path and adjust the path silently, so there's no errors


// It looks like it was installed on C:
foreach (var drive in Directory.GetLogicalDrives())
{
var hasNixInstalled = string.Format(@"{0}Program Files (x86)\MKVToolNix\", drive);

if (Directory.Exists(hasNixInstalled) && File.Exists(Path.Combine(hasNixInstalled, "mkvinfo.exe")))
{
var modPath = Environment.GetEnvironmentVariable("PATH") + ";" + hasNixInstalled;

// OK, looks like it was installed in the default directory
Environment.SetEnvironmentVariable("PATH",
modPath);

PathUtility.ExceptionalPath = modPath;

return true;
}


var hasNixInstalled32 = string.Format(@"{0}Program Files\MKVToolNix\", drive);


if (Directory.Exists(hasNixInstalled32) && File.Exists(Path.Combine(hasNixInstalled32, "mkvinfo.exe")))
{
var modPath = Environment.GetEnvironmentVariable("PATH") + ";" + hasNixInstalled32;
// OK, looks like it was installed in the default directory
Environment.SetEnvironmentVariable("PATH",
modPath);

PathUtility.ExceptionalPath = modPath;

return true;
}
}

MessageBox.Show(
"MKVToolNix and/or FFMPEG are missing from your system path. Please refer to the manual provided to install them for your platform.");
return false;
Expand Down Expand Up @@ -85,7 +129,7 @@ public bool IsRequirementMet()
// Check for the path's to the tools we required
try
{


PathUtility.FindExePath("perl.exe");
}
Expand Down

0 comments on commit 444093d

Please sign in to comment.