fix LuaConsole PWD-related bugs
This commit is contained in:
parent
0649d1c77e
commit
0fe74f95e7
|
@ -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)
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue