fix LuaConsole PWD-related bugs

This commit is contained in:
zeromus 2014-06-03 02:39:15 +00:00
parent 0649d1c77e
commit 0fe74f95e7
3 changed files with 8 additions and 10 deletions

View File

@ -21,11 +21,7 @@ namespace BizHawk.Client.Common
IsSeparator = false; IsSeparator = false;
// the current directory for the lua task will start off wherever the lua file is located // the current directory for the lua task will start off wherever the lua file is located
var directoryInfo = new FileInfo(path).Directory; CurrentDirectory = System.IO.Path.GetDirectoryName(path);
if (directoryInfo != null)
{
CurrentDirectory = directoryInfo.FullName;
}
} }
public LuaFile(bool isSeparator) public LuaFile(bool isSeparator)

View File

@ -127,7 +127,7 @@ namespace BizHawk.Client.EmuHawk
public Lua SpawnCoroutine(string file) public Lua SpawnCoroutine(string file)
{ {
var lua = _lua.NewThread(); var lua = _lua.NewThread();
var main = lua.LoadFile(file); var main = lua.LoadFile(PathManager.MakeAbsolutePath(file,null));
lua.Push(main); // push main function on to stack for subsequent resuming lua.Push(main); // push main function on to stack for subsequent resuming
return lua; return lua;
} }

View File

@ -383,7 +383,7 @@ namespace BizHawk.Client.EmuHawk
// Restore this lua thread's preferred current directory // Restore this lua thread's preferred current directory
if (lf.CurrentDirectory != null) if (lf.CurrentDirectory != null)
{ {
Environment.CurrentDirectory = lf.CurrentDirectory; Environment.CurrentDirectory = PathManager.MakeAbsolutePath(lf.CurrentDirectory, null);
} }
var result = LuaImp.ResumeScript(lf.Thread); var result = LuaImp.ResumeScript(lf.Thread);
@ -413,9 +413,11 @@ namespace BizHawk.Client.EmuHawk
MessageBox.Show(ex.ToString()); MessageBox.Show(ex.ToString());
} }
} }
finally
// Restore the current directory {
Environment.CurrentDirectory = oldcd; // Restore the current directory
Environment.CurrentDirectory = oldcd;
}
} }
} }
} }