Skip to content

Commit

Permalink
Merge pull request #28 from burninrubber0/FixAlignment
Browse files Browse the repository at this point in the history
Fix alignment
  • Loading branch information
burninrubber0 authored May 1, 2023
2 parents 10afe29 + 9f81e76 commit 91956e7
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 91956e7

Please sign in to comment.