/// <summary> /// Enumerates all non-archive local files, BLT encodes them and adds them to the InstallFile /// </summary> /// <param name="maxDegreeOfParallelism"></param> /// <returns></returns> public void ExportFiles(int maxDegreeOfParallelism = 15) { var results = new ConcurrentBag <CASRecord>(); var block = new ActionBlock <string>(file => { // strip the local path and normalise var name = file[(file.IndexOf(BaseDirectory, Comparison) + BaseDirectory.Length)..].WoWNormalise(); // block table encode and export to the temp folder // then add appropiate tags var record = BlockTableEncoder.EncodeAndExport(file, Options.TempDirectory, name); record.Tags = TagGenerator.GetTags(file); if (!EncodingCache.ContainsEKey(record.EKey)) { EncodingCache.AddOrUpdate(record); } else { record.BLTEPath = ""; } results.Add(record); },
/// <summary> /// Iterates all loose files within the data directory and BLT encodes them /// </summary> /// <param name="filenames"></param> public void EnumerateLooseDataFiles(IEnumerable <string> filenames) { if (!filenames.Any()) { return; } Log.WriteLine("Exporting loose Data files"); var block = new ActionBlock <string>(file => { var filename = GetInternalPath(file); var record = BlockTableEncoder.EncodeAndExport(file, Options.TempDirectory, filename); record.Tags = TagGenerator.GetTags(file); if (!EncodingCache.ContainsEKey(record.EKey)) { EncodingCache.AddOrUpdate(record); } else { record.BLTEPath = ""; } FileList.TryAdd(filename, record); }, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 150 }); foreach (var f in filenames) { block.Post(f); } block.Complete(); block.Completion.Wait(); }