diff --git a/BundleFormat/Extensions.cs b/BundleFormat/Extensions.cs index 00f01d5..3b9dd37 100644 --- a/BundleFormat/Extensions.cs +++ b/BundleFormat/Extensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.IO.Compression; @@ -106,13 +106,17 @@ public static bool VerifyMagic(this BinaryReader self, byte[] magic) public static void Align(this BinaryWriter self, byte alignment) { + long originalPosition = self.BaseStream.Position; self.BaseStream.Position = alignment * ((self.BaseStream.Position + (alignment - 1)) / alignment); - self.BaseStream.Position--; - self.Write((byte)0); + if (self.BaseStream.Position != originalPosition) + { + self.BaseStream.Position--; + self.Write((byte)0); + } /*long currentOffset = self.BaseStream.Position; for (int i = 0; i < (alignment - (currentOffset % alignment)); i++) self.Write((byte)0);*/ } } -} \ No newline at end of file +}