public void Downgrade() { if (fileMLVersion < TConstants.NewTmodVersion) { return; } fileTable = null; foreach (var kvp in files) { kvp.Value.OriginalData = GetTrueBytes(kvp.Value); kvp.Value.CompressedLength = kvp.Value.Length = kvp.Value.OriginalData.Length; kvp.Value.Offset = -1; } fileMLVersion = TConstants.OldTmodVersion; var buildProp = BuildProperties.ReadFromModFile(this); if (new Version(buildProp.BuildVersion) >= TConstants.NewTmodVersion) { buildProp.BuildVersion = TConstants.OldTmodVersion.ToString(); ReplaceFile(TConstants.InfoFileName, buildProp.ToBytes()); } Close(); }
public void Upgrade() { if (fileMLVersion >= TConstants.NewTmodVersion) { return; } fileTable = null; foreach (var fe in files) { CheckAndCompress(fe.Value); } fileMLVersion = TConstants.NewestTmodVersion; var buildProp = BuildProperties.ReadFromModFile(this); buildProp.BuildVersion = TConstants.NewestTmodVersion.ToString(); ReplaceFile(TConstants.InfoFileName, buildProp.ToBytes()); Close(); }
// Token: 0x0600199B RID: 6555 RVA: 0x00415054 File Offset: 0x00413254 public static void InfoToBuildTxt(Stream src, Stream dst) { BuildProperties buildProperties = BuildProperties.ReadFromStream(src); StringBuilder stringBuilder = new StringBuilder(); if (buildProperties.DisplayName.Length > 0) { stringBuilder.AppendLine("displayName = " + buildProperties.DisplayName); } if (buildProperties.Author.Length > 0) { stringBuilder.AppendLine("author = " + buildProperties.Author); } stringBuilder.AppendLine(string.Format("version = {0}", buildProperties.Version)); if (buildProperties.Homepage.Length > 0) { stringBuilder.AppendLine("homepage = " + buildProperties.Homepage); } if (buildProperties.DllReferences.Length != 0) { stringBuilder.AppendLine("dllReferences = " + string.Join(", ", buildProperties.DllReferences)); } if (buildProperties.ModReferences.Length != 0) { stringBuilder.AppendLine("modReferences = " + string.Join <BuildProperties.ModReference>(", ", buildProperties.ModReferences)); } if (buildProperties.WeakReferences.Length != 0) { stringBuilder.AppendLine("weakReferences = " + string.Join <BuildProperties.ModReference>(", ", buildProperties.WeakReferences)); } if (buildProperties.NoCompile) { stringBuilder.AppendLine("noCompile = true"); } if (buildProperties.HideCode) { stringBuilder.AppendLine("hideCode = true"); } if (buildProperties.HideResources) { stringBuilder.AppendLine("hideResources = true"); } if (buildProperties.IncludeSource) { stringBuilder.AppendLine("includeSource = true"); } if (buildProperties.IncludePdb) { stringBuilder.AppendLine("includePDB = true"); } if (buildProperties.Side != ModReference.ModSide.Both) { stringBuilder.AppendLine(string.Format("side = {0}", buildProperties.Side)); } if (buildProperties.SortAfter.Length != 0) { stringBuilder.AppendLine("sortAfter = " + string.Join(", ", buildProperties.SortAfter)); } if (buildProperties.SortBefore.Length != 0) { stringBuilder.AppendLine("sortBefore = " + string.Join(", ", buildProperties.SortBefore)); } byte[] bytes = Encoding.UTF8.GetBytes(stringBuilder.ToString()); dst.Write(bytes, 0, bytes.Length); }
public byte[] ToBytes() { byte[] result; using (MemoryStream memoryStream = new MemoryStream()) { using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) { if (DllReferences.Length != 0) { binaryWriter.Write("dllReferences"); BuildProperties.WriteList <string>(this.DllReferences, binaryWriter); } if (ModReferences.Length != 0) { binaryWriter.Write("modReferences"); BuildProperties.WriteList <BuildProperties.ModReference>(this.ModReferences, binaryWriter); } if (WeakReferences.Length != 0) { binaryWriter.Write("weakReferences"); BuildProperties.WriteList <BuildProperties.ModReference>(this.WeakReferences, binaryWriter); } if (SortAfter.Length != 0) { binaryWriter.Write("sortAfter"); BuildProperties.WriteList <string>(this.SortAfter, binaryWriter); } if (SortBefore.Length != 0) { binaryWriter.Write("sortBefore"); BuildProperties.WriteList <string>(this.SortBefore, binaryWriter); } if (this.Author.Length > 0) { binaryWriter.Write("author"); binaryWriter.Write(this.Author); } binaryWriter.Write("version"); binaryWriter.Write(Version); if (this.DisplayName.Length > 0) { binaryWriter.Write("displayName"); binaryWriter.Write(this.DisplayName); } if (this.Homepage.Length > 0) { binaryWriter.Write("homepage"); binaryWriter.Write(this.Homepage); } if (this.Description.Length > 0) { binaryWriter.Write("description"); binaryWriter.Write(this.Description); } if (this.NoCompile) { binaryWriter.Write("noCompile"); } if (!this.HideCode) { binaryWriter.Write("!hideCode"); } if (!this.HideResources) { binaryWriter.Write("!hideResources"); } if (this.IncludeSource) { binaryWriter.Write("includeSource"); } if (this.IncludePdb) { binaryWriter.Write("includePDB"); } if (this.EacPath.Length > 0) { binaryWriter.Write("eacPath"); binaryWriter.Write(this.EacPath); } if (this.Side != ModReference.ModSide.Both) { binaryWriter.Write("side"); binaryWriter.Write((byte)this.Side); } binaryWriter.Write("buildVersion"); binaryWriter.Write(BuildVersion); binaryWriter.Write(""); } result = memoryStream.ToArray(); } return(result); }
// // Token: 0x06001999 RID: 6553 RVA: 0x00414DDC File Offset: 0x00412FDC // internal static BuildProperties ReadModFile(TmodFile modFile) // { // return BuildProperties.ReadFromStream(modFile.GetStream("Info", false)); // } // Token: 0x0600199A RID: 6554 RVA: 0x00414DF0 File Offset: 0x00412FF0 public static BuildProperties ReadFromStream(Stream stream) { BuildProperties buildProperties = new BuildProperties(); using (BinaryReader binaryReader = new BinaryReader(stream)) { string text = binaryReader.ReadString(); while (text.Length > 0) { if (text == "dllReferences") { buildProperties.DllReferences = BuildProperties.ReadList(binaryReader).ToArray <string>(); } if (text == "modReferences") { buildProperties.ModReferences = BuildProperties.ReadList(binaryReader).Select(new Func <string, BuildProperties.ModReference>(BuildProperties.ModReference.Parse)).ToArray <BuildProperties.ModReference>(); } if (text == "weakReferences") { buildProperties.WeakReferences = BuildProperties.ReadList(binaryReader).Select(new Func <string, BuildProperties.ModReference>(BuildProperties.ModReference.Parse)).ToArray <BuildProperties.ModReference>(); } if (text == "sortAfter") { buildProperties.SortAfter = BuildProperties.ReadList(binaryReader).ToArray <string>(); } if (text == "sortBefore") { buildProperties.SortBefore = BuildProperties.ReadList(binaryReader).ToArray <string>(); } if (text == "author") { buildProperties.Author = binaryReader.ReadString(); } if (text == "version") { buildProperties.Version = binaryReader.ReadString(); } if (text == "displayName") { buildProperties.DisplayName = binaryReader.ReadString(); } if (text == "homepage") { buildProperties.Homepage = binaryReader.ReadString(); } if (text == "description") { buildProperties.Description = binaryReader.ReadString(); } if (text == "noCompile") { buildProperties.NoCompile = true; } if (text == "!hideCode") { buildProperties.HideCode = false; } if (text == "!hideResources") { buildProperties.HideResources = false; } if (text == "includeSource") { buildProperties.IncludeSource = true; } if (text == "includePDB") { buildProperties.IncludePdb = true; } if (text == "eacPath") { buildProperties.EacPath = binaryReader.ReadString(); } if (text == "side") { buildProperties.Side = (ModReference.ModSide)binaryReader.ReadByte(); } if (text == "beta") { buildProperties.Beta = true; } if (text == "buildVersion") { buildProperties.BuildVersion = binaryReader.ReadString(); } text = binaryReader.ReadString(); } } return(buildProperties); }