internal static LocalMod[] FindMods()
{
Directory.CreateDirectory(ModPath);
var mods = new List <LocalMod>();
foreach (string fileName in Directory.GetFiles(ModPath, "*.tmod", SearchOption.TopDirectoryOnly))
{
var lastModified = File.GetLastWriteTime(fileName);
if (!modsDirCache.TryGetValue(fileName, out var mod) || mod.lastModified != lastModified)
{
var modFile = new TmodFile(fileName);
try
{
modFile.Read(TmodFile.LoadedState.Info);
}
catch (Exception e) //this will probably spam, given the number of calls to FindMods
{
ErrorLogger.LogException(e, Language.GetTextValue("tModLoader.LoadErrorErrorReadingModFile", modFile.path));
continue;
}
mod = new LocalMod(modFile)
{
lastModified = lastModified
};
modsDirCache[fileName] = mod;
}
mods.Add(mod);
}
return(mods.OrderBy(x => x.Name, StringComparer.InvariantCulture).ToArray());
}