Command line: Fixed loading roms with relative path

This commit is contained in:
Souryo 2016-12-20 22:44:43 -05:00
parent 6cee4544cb
commit ed3ca11271
2 changed files with 17 additions and 4 deletions

View File

@ -72,10 +72,20 @@ namespace Mesen.GUI.Forms
if(args.Length > 0) {
foreach(string arg in args) {
if(File.Exists(arg)) {
this.LoadFile(arg);
break;
}
string path = arg;
try {
if(File.Exists(path)) {
this.LoadFile(path);
break;
}
//Try loading file as a relative path to the folder Mesen was started from
path = Path.Combine(Program.OriginalFolder, path);
if(File.Exists(path)) {
this.LoadFile(path);
break;
}
} catch { }
}
}
}

View File

@ -21,6 +21,7 @@ namespace Mesen.GUI
private static extern bool SetForegroundWindow(IntPtr hWnd);
public static bool IsMono { get; private set; }
public static string OriginalFolder { get; private set; }
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
@ -63,6 +64,8 @@ namespace Mesen.GUI
if(Type.GetType("Mono.Runtime") != null) {
Program.IsMono = true;
}
Program.OriginalFolder = Directory.GetCurrentDirectory();
AppDomain.CurrentDomain.AssemblyResolve += LoadAssemblies;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);