Skip to content

Commit

Permalink
refactor: remove partition write function
Browse files Browse the repository at this point in the history
  • Loading branch information
swysocki committed Aug 2, 2022
1 parent d28dd28 commit be423c7
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions gpt_image/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,3 @@ def write(self) -> None:
f.seek(self.geometry.alternate_array_byte)
f.write(self.table.partitions.marshal())

def write_data(self, data: bytes, partition: Partition, offset: int = 0) -> None:
# @NOTE: this isn't a GPT function. Writing data should be outside the scope of
# this module
"""Write data to a disk partition
Args:
data: data to write to partition. only bytes supported
partition: Partition object data will be written to
offset: byte offset for writing data. The default is 0 but can be set to
support custom offsets
Raises:
ValueError if data not is not bytes
"""

if not type(data) is bytes:
raise ValueError(f"data must be of type bytes. found type: {type(data)}")

with open(self.image_path, "r+b") as f:
start_byte = int(partition.first_lba * self.sector_size)
with open(self.image_path, "r+b") as f:
f.seek(start_byte + offset)
f.write(data)

0 comments on commit be423c7

Please sign in to comment.