Skip to content

Commit

Permalink
Fix alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
burninrubber0 committed May 1, 2023
1 parent 10afe29 commit 9f81e76
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions BundleFormat/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -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);*/
}
}
}
}

0 comments on commit 9f81e76

Please sign in to comment.