public static void ImportSkills(this OGLContext context, bool withZips = true) { if (context == null || context.Config == null) { return; } if (withZips) { context.Skills.Clear(); context.SkillsSimple.Clear(); } var files = SourceManager.EnumerateFiles(context, context.Config.Skills_Directory, withZips, SearchOption.TopDirectoryOnly); foreach (var f in files) { try { using (Stream reader = f.Value.GetReader()) OGLImport.ImportSkill(reader, f.Value.FullName, f.Value.Source, context); } catch (Exception e) { ConfigManager.LogError("Error reading " + f.ToString(), e); } } }
public static async Task ImportSkillsAsync(this OGLContext context, bool withZips = true) { if (withZips) { context.Skills.Clear(); context.SkillsSimple.Clear(); foreach (IFile z in PCLSourceManager.Zips) { String s = System.IO.Path.ChangeExtension(z.Name, null); if (context.ExcludedSources.Contains(s, StringComparer.OrdinalIgnoreCase)) { continue; } using (ZipFile zf = new ZipFile(await z.OpenAsync(FileAccess.Read))) { var zfiles = await PCLSourceManager.EnumerateZipFilesAsync(zf, s, context.Config.Skills_Directory).ConfigureAwait(false); foreach (var f in zfiles) { try { using (Stream reader = zf.GetInputStream(f.Value)) OGLImport.ImportSkill(reader, f.Key, s, context); } catch (Exception e) { ConfigManager.LogError("Error reading " + Path(f.Key), e); } } } } } var files = await PCLSourceManager.EnumerateFilesAsync(context, context.Config.Skills_Directory).ConfigureAwait(false); foreach (var f in files) { try { using (Stream reader = await f.Key.OpenAsync(FileAccess.Read).ConfigureAwait(false)) OGLImport.ImportSkill(reader, f.Key.Path, f.Value, context); } catch (Exception e) { ConfigManager.LogError("Error reading " + Path(f.Key.Path), e); } } }