From 0c973514d9e3e323373fae7aa8c3d3dd413dc969 Mon Sep 17 00:00:00 2001 From: arookas Date: Thu, 10 Dec 2015 17:51:21 -0500 Subject: [PATCH] Merged logic between main- and sub- script import. --- import resolver.cs | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/import resolver.cs b/import resolver.cs index 72d859a..84be586 100644 --- a/import resolver.cs +++ b/import resolver.cs @@ -20,6 +20,7 @@ namespace arookas List imports = new List(10); Stack current = new Stack(5); string rootDirectory, currentDirectory; + string CurrentDirectory { get { return current.Count > 0 ? Path.GetDirectoryName(current.Peek().Name) : currentDirectory; } } public sunDefaultImportResolver() { @@ -44,24 +45,12 @@ namespace arookas } else { - if (current.Count > 0) + // check if the file exists relative to the current one; + // if it's not there, check the root directory + fullPath = Path.Combine(CurrentDirectory, name); + if (!File.Exists(fullPath)) { - // check if the file exists relative to the current one; - // if it's not there, check the root directory - fullPath = Path.Combine(Path.GetDirectoryName(current.Peek().Name), name); - if (!File.Exists(fullPath)) - { - fullPath = Path.Combine(rootDirectory, name); - if (!File.Exists(fullPath)) - { - return sunImportResult.Missing; - } - } - } - else - { - // if this is the main script file (i.e. current stack is empty), just use the current directory - fullPath = Path.Combine(currentDirectory, name); + fullPath = Path.Combine(rootDirectory, name); if (!File.Exists(fullPath)) { return sunImportResult.Missing;