diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs b/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
index a95a1100..7a5bf67e 100644
--- a/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
@@ -1237,9 +1237,11 @@ namespace UniversalEditor.IO
/// aligned position.
///
/// The number of bytes on which to align the .
- public void Align(int alignTo)
+ /// Any additional padding bytes that should be included after aligning to the specified boundary.
+ public void Align(int alignTo, int extraPadding = 0)
{
long paddingCount = ((alignTo - (base.Accessor.Position % alignTo)) % alignTo);
+ paddingCount += extraPadding;
base.Accessor.Position += paddingCount;
}
diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs b/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
index 50741b5e..7789367d 100644
--- a/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
@@ -535,38 +535,19 @@ namespace UniversalEditor.IO
return num;
}
-
- public void Align(int paddingCount)
+ ///
+ /// Aligns the to the specified number of bytes. If the current
+ /// position of the is not a multiple of the specified number of bytes,
+ /// the position will be increased by the amount of bytes necessary to bring it to the
+ /// aligned position.
+ ///
+ /// The number of bytes on which to align the .
+ /// Any additional padding bytes that should be included after aligning to the specified boundary.
+ public void Align(int alignTo, int extraPadding = 0)
{
- switch (paddingCount)
- {
- case 2:
- {
- long position = base.Accessor.Position;
- int num = (int)(position % 2L);
- byte[] array = new byte[num];
- array.Initialize();
- WriteBytes(array);
- break;
- }
- case 4:
- {
- long num = base.Accessor.Position;
- num = (num + 3L & -4L);
- long num2 = num - base.Accessor.Position;
- byte[] array = new byte[num2];
- array.Initialize();
- WriteBytes(array);
- break;
- }
- default:
- {
- long count = (base.Accessor.Position % paddingCount);
- byte[] array = new byte[count];
- WriteBytes(array);
- break;
- }
- }
+ long paddingCount = ((alignTo - (base.Accessor.Position % alignTo)) % alignTo);
+ paddingCount += extraPadding;
+ base.Accessor.Position += paddingCount;
}