From 6f733cf981bd090d1e96f778210bb70bb5a47752 Mon Sep 17 00:00:00 2001 From: V <82741743+SamuraiOndo@users.noreply.github.com> Date: Mon, 2 Oct 2023 13:43:18 -0500 Subject: [PATCH] add custom byte support to BinaryReader().pad() --- binary_reader/binary_reader.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/binary_reader/binary_reader.py b/binary_reader/binary_reader.py index de05b11..a03c68a 100644 --- a/binary_reader/binary_reader.py +++ b/binary_reader/binary_reader.py @@ -108,14 +108,14 @@ def buffer(self) -> bytearray: """Returns the buffer as a bytearray.""" return bytearray(self.__buf) - def pad(self, size: int) -> None: - """Pads the buffer by 0s with the given size and advances the buffer position.\n + def pad(self, size: int, paddingByte: int = 0) -> None: + """Pads the buffer with the given byte (defaults to 0) with the given size and advances the buffer position.\n Will advance the buffer position only if the position was at the end of the buffer. """ if self.__idx == self.size(): self.__idx += size - self.extend([0] * size) + self.extend([paddingByte] * size) def align_pos(self, size: int) -> int: """Aligns the current position to the given size.\n