diff --git a/YesNt.Interpreter/Runtime/YesNtInterpreter.cs b/YesNt.Interpreter/Runtime/YesNtInterpreter.cs index ce07f9b..7445996 100644 --- a/YesNt.Interpreter/Runtime/YesNtInterpreter.cs +++ b/YesNt.Interpreter/Runtime/YesNtInterpreter.cs @@ -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)); diff --git a/YesNt.Interpreter/Statements/ProcessingStatements.cs b/YesNt.Interpreter/Statements/ProcessingStatements.cs index 282bcad..5efe797 100644 --- a/YesNt.Interpreter/Statements/ProcessingStatements.cs +++ b/YesNt.Interpreter/Statements/ProcessingStatements.cs @@ -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");