mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-04 09:06:41 +02:00
Use correct directory when importing other file
This commit is contained in:
@@ -258,6 +258,8 @@ namespace YesNt.Interpreter.Runtime
|
||||
|
||||
private bool LoadFile(string path)
|
||||
{
|
||||
path = Path.GetFullPath(path);
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine($"File \"{path}\" not found!");
|
||||
@@ -272,6 +274,8 @@ namespace YesNt.Interpreter.Runtime
|
||||
return false;
|
||||
}
|
||||
|
||||
runtimeInfo.WorkingDirectory = Path.GetDirectoryName(path);
|
||||
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
runtimeInfo.Lines.Add(new Line(lines[i], Path.GetFileName(path), i));
|
||||
|
||||
@@ -86,6 +86,8 @@ namespace YesNt.Interpreter.Statements
|
||||
[Statement("imp", SearchMode.StartOfLine, SpaceAround.End, ConsoleColor.Magenta)]
|
||||
public void Import(string path)
|
||||
{
|
||||
path = Path.Combine(RuntimeInfo.WorkingDirectory, path);
|
||||
|
||||
if (string.IsNullOrEmpty(Path.GetExtension(path)))
|
||||
{
|
||||
path = Path.ChangeExtension(path, "ynt");
|
||||
|
||||
Reference in New Issue
Block a user