protected virtual List<string> ReadScriptList(string scriptListFile)
{
var result = new List<string>();
using (var fr = new FileReader(scriptListFile))
{
foreach (var line in fr)
{
var scriptPath = line.Value;
// Path relative to cwd
if (scriptPath.StartsWith("/"))
{
scriptPath = Path.Combine(Directory.GetCurrentDirectory().Replace("\\", "/"), scriptPath.Replace("\\", "/").TrimStart('/')).Replace("\\", "/");
}
// Path relative to list file
else
{
// Get path to the current list's directory
var listPath = Path.GetFullPath(line.File);
listPath = Path.GetDirectoryName(listPath);
// Get full path to script
scriptPath = Path.Combine(listPath, scriptPath).Replace("\\", "/");
}
var paths = new List<string>();
if (!scriptPath.EndsWith("/*"))
{
paths.Add(scriptPath);
}
else
{
var recursive = scriptPath.EndsWith("/**/*");
var directoryPath = scriptPath.TrimEnd('/', '*');
if (Directory.Exists(directoryPath))
{
foreach (var file in Directory.EnumerateFiles(directoryPath, "*", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly))
{
// Ignore "hidden" files
if (Path.GetFileName(file).StartsWith("."))
continue;
paths.Add(file.Replace("\\", "/"));
}
}
else
{
Log.Warning("ReadScriptList: Directory not found: {0}", directoryPath);
}
}
foreach (var path in paths)
{
if (!result.Contains(path))
result.Add(path);
}
}
}
return result;
}