Browse Source

Add padding method in MemoryStream

master
BahaBulle 8 years ago
parent
commit
62764fee9a
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      Hack.Xenosaga/Common/Extension.cs

+ 16
- 0
Hack.Xenosaga/Common/Extension.cs View File

@ -40,5 +40,21 @@ namespace Hack.Xenosaga.Common
return value; return value;
} }
/// <summary>
/// Pad a MemoryStream with a byte
/// </summary>
/// <param name="modulo">Modulo to use for the padding (default: 4)</param>
/// <param name="value">Value of the byte (default: 0)</param>
public static void Padding(this MemoryStream ms, int modulo = 4, byte value = 0)
{
long size = ms.Length;
while (size % modulo != 0)
{
ms.WriteByte(value);
size++;
}
}
} }
} }

Loading…
Cancel
Save