/// <summary> /// Save the specified tag's data over the head revision of the specified tag file. /// </summary> private void SaveTagToHeadRevision(Tag tag, TagFile tagFile) { tagFile.SetHeadBinary(tag.Save()); ILibrary targetLibrary = GetLibrary(tag.TagPath); targetLibrary.AddFile(tag.TagPath.Path + "." + tag.TagPath.Extension, tagFile.ToBytes()); }
public byte[] GetTag(string path) { Tag tag = LoadTag(path); TagFile tf = new TagFile(tag.GetTagData(), "Bungie", "Obtained from Halo 2 Xbox.", typeTable.LocateEntryByTypecode(tag.Type).FourCC, "????", "????", Halo2XboxGameDefinition.TagIdentifierStatic); tf.AddAttachment(ExtraTagDataAttachmentName); tf.AddAttachmentRevision(ExtraTagDataAttachmentName, tag.GetExtraData(), 1.0f, CompressionStyle.GZip); return(tf.ToBytes()); }
public void PerformTest() { GameDefinition def = Core.Prometheus.Instance.GetGameDefinitionByGameID("halo1pc"); FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.Cancel) { return; } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Prometheus Tag Archive (*.pta)|*.pta"; sfd.AddExtension = true; if (sfd.ShowDialog() == DialogResult.Cancel) { return; } TagArchive archive = new TagArchive(sfd.FileName, Archive.ArchiveMode.Open); string[] files = Helpers.GetRecursiveFiles(fbd.SelectedPath); foreach (string file in files) { FileStream stream = new FileStream(file, FileMode.Open); stream.Position = 0x8; string[] classes = new string[] { ReadClass(stream), ReadClass(stream), ReadClass(stream) }; stream.Position = 0x40; byte[] data = new byte[stream.Length - 40]; stream.Read(data, 0, (int)stream.Length - 40); TagFile tag = new TagFile(data, "Bungie", "Obtained from Halo PC.", classes[0], classes[1], classes[2], Encoding.ASCII.GetBytes(def.GameID)); byte[] tagBin = tag.ToBytes(); string fullPath = file.Substring(fbd.SelectedPath.Length + 1); string folder = Path.GetDirectoryName(fullPath); string extension = def.TypeTable.LocateEntryByFourCC(classes[0]).FullName; string filename = Path.GetFileNameWithoutExtension(fullPath) + "." + extension; archive.AddFile(folder + "\\" + filename, tagBin); } archive.Close(); }