New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEVTOOLS: dumper-companion: Support images with multiple partitions; don't warn about missing deps when not running mac mode #5412
Conversation
…don't warn about missing deps when not running mac mode Additionally fix a copy/paste error and remove an unused variable.
WalkthroughWalkthroughThe recent changes in the Changes
TipsChat with CodeRabbit Bot (
|
partitions = [] | ||
with source_volume.open(mode="rb") as f: | ||
f.seek(0x200) | ||
if f.read(4) == b"PM\x00\x00": | ||
partition_num = 1 | ||
partition_type = "" | ||
while partition_type != "Apple_HFS": | ||
partition_num = 1 | ||
|
||
while True: | ||
data = f.read(4) | ||
if data == b"PM\x00\x00": | ||
num_partitions, partition_start, partition_size = unpack( | ||
">III", f.read(12) | ||
) | ||
f.seek(32, 1) | ||
partition_type = f.read(32).decode("ascii").split("\x00")[0] | ||
if partition_num <= num_partitions and partition_type != "Apple_HFS": | ||
f.seek(0x20, 1) | ||
partition_type = f.read(0x20).decode("ascii").split("\x00")[0] | ||
if partition_type == "Apple_HFS" and partition_size > 0: | ||
# Found an HFS partition, log it | ||
partitions.append((partition_start * 0x200, partition_size * 0x200)) | ||
if partition_num <= num_partitions: | ||
# Move onto the next partition | ||
partition_num += 1 | ||
f.seek(partition_num * 0x200 + 4) | ||
f.seek(partition_num * 0x200) | ||
else: | ||
# We found the one we want or there's none | ||
# Finished parsing the partition map | ||
break | ||
f.seek(partition_start * 0x200) | ||
vol.read(f.read(partition_size * 0x200)) | ||
else: | ||
# Didn't find the Apple Partition Map, break so we can just | ||
# load the entire image | ||
break | ||
|
||
if partitions: | ||
for partition_start, partition_size in partitions: | ||
f.seek(partition_start) | ||
vol.read(f.read(partition_size)) | ||
extract_partition(args, vol) | ||
else: | ||
f.seek(0) | ||
vol.read(f.read()) | ||
extract_partition(args, vol) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for handling partitioned volumes seems sound. It reads the partition map, identifies HFS partitions, and then extracts each partition using the new extract_partition
function. However, error handling is missing. Consider adding try-except blocks to handle potential IO errors.
Thank you! |
This was inspired by a LucasArts disc having an additional (empty) HFS partition on the disc. Missing dependency warning was moved so as to not annoy users who only want to use the other modes.