/// <summary> /// Iterates all the data archives, extracting and BLT encoding all files /// <para>Patches are applied where applicable to get the most up-to-date variant of each file.</para> /// </summary> /// <param name="archives"></param> public void EnumerateDataArchives(IEnumerable <string> archives, bool applyTags = false) { Log.WriteLine("Exporting Data Archive files"); foreach (var archivename in archives) { using var mpq = new MpqArchive(archivename, FileAccess.Read); Log.WriteLine(" Exporting " + Path.GetFileName(mpq.FilePath)); if (TryGetListFile(mpq, out var files)) { mpq.AddPatchArchives(PatchArchives); ExportFiles(mpq, files, applyTags).Wait(); mpq.Dispose(); } else if (TryReadAlpha(mpq, archivename)) { mpq.Dispose(); } else { throw new FormatException(Path.GetFileName(archivename) + " HAS NO LISTFILE!"); } } }
/// <summary> /// Reads a specific file from an archive. Will parse the archive name if no filename is specified (Hot Swappable). /// </summary> /// <param name="archivename"></param> /// <param name="filename"></param> /// <returns></returns> public IFormat ReadFile(string filename, string archivename) { if (!_archiveLocks.TryGetValue(archivename, out MpqArchive mpq)) { mpq = new MpqArchive(archivename, FileAccess.Read); mpq.AddPatchArchives(_patchArchives); _archiveLocks.TryAdd(archivename, mpq); } // add the filename to the alpha mpqs an set the flat filename string overridename = null; if (archivename.Contains(filename, StringComparison.OrdinalIgnoreCase)) { overridename = Path.GetFileName(filename); mpq.AddListFile(overridename); } return(ReadFileImpl(mpq, filename, overridename)); }
/// <summary> /// Iterates all the patch archives, extracting and BLT encoding all new files /// NOTE: Looks like stormlib handles this automatically with AddPatchArchive(s) /// </summary> public void EnumeratePatchArchives() { if (PatchArchives.Count == 0) { return; } Log.WriteLine("Exporting Patch Archive files"); while (PatchArchives.Count > 0) { using var mpq = new MpqArchive(PatchArchives.Dequeue(), FileAccess.Read); Log.WriteLine(" Exporting " + Path.GetFileName(mpq.FilePath)); if (!TryGetListFile(mpq, out var files)) { throw new Exception(Path.GetFileName(mpq.FilePath) + " MISSING LISTFILE"); } mpq.AddPatchArchives(PatchArchives); ExportFiles(mpq, files).Wait(); mpq.Dispose(); } }