Merged logic between main- and sub- script import.
This commit is contained in:
parent
85d85695e2
commit
0c973514d9
1 changed files with 6 additions and 17 deletions
|
@ -20,6 +20,7 @@ namespace arookas
|
|||
List<sunScriptFile> imports = new List<sunScriptFile>(10);
|
||||
Stack<sunScriptFile> current = new Stack<sunScriptFile>(5);
|
||||
string rootDirectory, currentDirectory;
|
||||
string CurrentDirectory { get { return current.Count > 0 ? Path.GetDirectoryName(current.Peek().Name) : currentDirectory; } }
|
||||
|
||||
public sunDefaultImportResolver()
|
||||
{
|
||||
|
@ -43,12 +44,10 @@ 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(Path.GetDirectoryName(current.Peek().Name), name);
|
||||
fullPath = Path.Combine(CurrentDirectory, name);
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
fullPath = Path.Combine(rootDirectory, name);
|
||||
|
@ -58,16 +57,6 @@ namespace arookas
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if this is the main script file (i.e. current stack is empty), just use the current directory
|
||||
fullPath = Path.Combine(currentDirectory, name);
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
return sunImportResult.Missing;
|
||||
}
|
||||
}
|
||||
}
|
||||
// make sure the file has not been imported yet
|
||||
if (imports.Any(i => i.Name == fullPath))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue