public bool TryGetModuleFile(string path, string parentDirectory, out ModuleFile moduleFile)
{
moduleFile = null;
// Alias?
if (path.Contains(":"))
{
moduleFile = this.GetModuleFile(path);
return true;
}
else
{
var fileName = JsonHelper.GetFileFromFileJson(path, parentDirectory);
// Is it a valid filename?
if (!File.Exists(fileName))
return false; // Not a valid file => we don't stand a chance to begin with
// Cut away the unrequired bits
var simplifiedFileName = fileName.Replace(ModuleDataManager.GetInstance().ModsDirectoryPath, "").TrimStart(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
// Split it into mod/path within mod
var parts = simplifiedFileName.Split(new[] { System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar }, 2);
var mod = ModuleDataManager.GetInstance().GetMod(parts[0]);
if (mod == null)
return false;
// The file exists, but we can't say much beyond that.
return true;
////// Get all aliases that match this file
////var aliases = mod.GetAliases().Where(alias => alias.ResolvedPath == fileName).ToList();
////return null;
}
}