/// <summary>Align the stream's position by a certain page boundry</summary> /// <param name="alignmentBit">log2 size of the alignment (ie, 1<<bit)</param> /// <returns>True if any alignment had to be performed, false if otherwise</returns> public bool AlignToBoundry(int alignmentBit) { int align_size = IntegerMath.PaddingRequired(alignmentBit, (uint)BaseStream.Position); if (align_size > 0) { BaseStream.Seek(align_size, SeekOrigin.Current); return(true); } return(false); }
public uint CalculatePadding(uint offset) { const int kAlignmentBit = IntegerMath.kInt32AlignmentBit; PrePadSize = 0; if (Type != XmbVariantType.String) { PrePadSize = (byte)IntegerMath.PaddingRequired(kAlignmentBit, offset); } return(PrePadSize); }
/// <summary>Align the stream's position by a certain page boundry</summary> /// <param name="alignmentBit">log2 size of the alignment (ie, 1<<bit)</param> /// <returns>True if any alignment had to be performed, false if otherwise</returns> public bool AlignToBoundry(int alignmentBit) { int align_size = IntegerMath.PaddingRequired(alignmentBit, (uint)BaseStream.Position); if (align_size > 0) { while (align_size-- > 0) { BaseStream.WriteByte(byte.MinValue); } return(true); } return(false); }
public uint CalculatePadding(uint offset, bool willWriteSizeToo) { PrePadSize = 0; int alignment_bit = System.Math.Max(TypeDesc.AlignmentBit, IntegerMath.kInt32AlignmentBit); if (Type != BinaryDataTreeVariantType.String) { PrePadSize = (byte)IntegerMath.PaddingRequired(alignment_bit, offset); } if (willWriteSizeToo) { PrePadSize += sizeof(uint); } return(PrePadSize); }