[Scummvm-git-logs] scummvm master -> e43224c4d9cd79e81bd4c7a3dbff046692aa9d6c
sev-
noreply at scummvm.org
Thu Jun 16 11:59:54 UTC 2022
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9c5f3065b0 DEVTOOLS: Add basic Apple partition parsing, recursively set folder modtimes
2583c5ea71 DEVTOOLS: Add flags to mac mode
9bd355e9ad DEVTOOLS: Simplify data/rsrc padding
e43224c4d9 DEVTOOLS: Format with `black`
Commit: 9c5f3065b0b53c978d55aa195069736180d1c5f6
https://github.com/scummvm/scummvm/commit/9c5f3065b0b53c978d55aa195069736180d1c5f6
Author: eientei (einstein95 at users.noreply.github.com)
Date: 2022-06-16T13:59:50+02:00
Commit Message:
DEVTOOLS: Add basic Apple partition parsing, recursively set folder modtimes
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index 180e84a9024..26413bf87e7 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -281,7 +281,28 @@ def extract_volume(args: argparse.Namespace) -> int:
print(f"Loading {source_volume} ...")
vol = machfs.Volume()
- vol.read(source_volume.read_bytes())
+ with source_volume.open(mode='rb') as f:
+ f.seek(0x200)
+ if f.read(4) == b'PM\0\0':
+ partition_num = 1
+ partition_type = ''
+ while partition_type != 'Apple_HFS':
+ num_partitions, partition_start, partition_size = unpack('>III', f.read(12))
+ f.seek(32, 1)
+ partition_type = f.read(32).decode('ascii').strip('\0')
+ if partition_num <= num_partitions and partition_type != 'Apple_HFS':
+ # Move onto the next partition
+ partition_num += 1
+ f.seek(partition_num * 0x200 + 4)
+ else:
+ # We found the one we want or there's none
+ break
+
+ f.seek(partition_start * 0x200)
+ vol.read(f.read(partition_size * 0x200))
+ else:
+ f.seek(0)
+ vol.read(f.read())
destination_dir.mkdir(parents=True, exist_ok=True)
for hpath, obj in vol.iter_paths():
@@ -302,15 +323,22 @@ def extract_volume(args: argparse.Namespace) -> int:
os.utime(upath, (obj.mddate - 2082844800, obj.mddate - 2082844800))
else:
print(upath)
- file = obj.data
- if obj.rsrc:
- file = file_to_macbin(obj, hpath[-1].encode("mac_roman"))
- upath.write_bytes(file)
+ if obj.data and not obj.rsrc:
+ upath.write_bytes(obj.data)
+
+ elif obj.rsrc:
+ upath.write_bytes(file_to_macbin(obj, hpath[-1].encode('mac_roman')))
+
+ elif not obj.data and not obj.rsrc:
+ upath.touch()
+
os.utime(upath, (obj.mddate - 2082844800, obj.mddate - 2082844800))
# This needs to be done after writing files as writing files resets
# the parent folder's modified time that was set before
- parent_folder_modtime = vol.get(hpath[:-1]).mddate - 2082844800
- os.utime(upath.parent, (parent_folder_modtime, parent_folder_modtime))
+ if len(hpath) > 1:
+ for i in range(len(hpath), 0, -1):
+ parent_folder_modtime = vol.get(hpath[:i]).mddate - 2082844800
+ os.utime(Path(*(upath.parts[:i])), (parent_folder_modtime, parent_folder_modtime))
return 0
Commit: 2583c5ea71e5b684f15f66b7f75a975e3dee8457
https://github.com/scummvm/scummvm/commit/2583c5ea71e5b684f15f66b7f75a975e3dee8457
Author: eientei (einstein95 at users.noreply.github.com)
Date: 2022-06-16T13:59:50+02:00
Commit Message:
DEVTOOLS: Add flags to mac mode
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index 26413bf87e7..10fc43ba478 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -12,7 +12,7 @@
# This file contains tests. They can be run with:
# $ pytest dumper-companion.py
#
-# Code is formatted with `black `
+# Code is formatted with `black`
import argparse
import io
@@ -462,12 +462,12 @@ def collect_forks(args: argparse.Namespace) -> int:
# Get info on creator and type
try:
- finderInfo = xattr.xattr(filepath)["com.apple.FinderInfo"][0:8]
+ finderInfo = xattr.xattr(filepath)["com.apple.FinderInfo"][0:9]
except (IOError, OSError) as e:
print(f"Error getting type and creator for: {filename}")
return 1
- file.type, file.creator = unpack("4s4s", finderInfo)
+ file.type, file.creator, file.flags = unpack("4s4sB", finderInfo)
with open(resourcepath, "rb") as rsrc:
file.rsrc = rsrc.read()
Commit: 9bd355e9ad99b27fb90a77c33cf2be4b0ab9184a
https://github.com/scummvm/scummvm/commit/9bd355e9ad99b27fb90a77c33cf2be4b0ab9184a
Author: eientei (einstein95 at users.noreply.github.com)
Date: 2022-06-16T13:59:50+02:00
Commit Message:
DEVTOOLS: Simplify data/rsrc padding
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index 10fc43ba478..bdddf065560 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -159,13 +159,11 @@ def file_to_macbin(f: machfs.File, name: ByteString) -> bytes:
macbin += pack(">H2x", crc_hqx(macbin, 0))
if f.data:
macbin += f.data
- if len(f.data) % 128:
- macbin += b"\x00" * (128 - len(f.data) % 128)
+ macbin += b"\x00" * (-len(f.data) % 128)
if f.rsrc:
macbin += f.rsrc
- if len(f.rsrc) % 128:
- macbin += b"\x00" * (128 - len(f.rsrc) % 128)
+ macbin += b"\x00" * (-len(f.rsrc) % 128)
return macbin
@@ -273,7 +271,7 @@ def generate_punyencoded_path(destination_dir: Path, hpath: Tuple[str]) -> Path:
def extract_volume(args: argparse.Namespace) -> int:
- """Extract an mac iso"""
+ """Extract an HFS volume"""
source_volume: Path = args.src
destination_dir: Path = args.dir
punify: bool = args.punycode
@@ -501,14 +499,14 @@ def generate_parser() -> argparse.ArgumentParser:
"""
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
- parser_iso = subparsers.add_parser("iso", help="Dump hfs isos")
+ parser_iso = subparsers.add_parser("iso", help="Dump HFS isos")
parser_iso.add_argument("src", metavar="INPUT", type=Path, help="Disk image")
parser_iso.add_argument(
"--punycode", action="store_true", help="encode pathnames into punycode"
)
parser_iso.add_argument(
- "--japanese", action="store_true", help="read mac_japanese hfs+"
+ "--japanese", action="store_true", help="read mac-japanese HFS"
)
parser_iso.add_argument(
"dir", metavar="OUTPUT", type=Path, help="Destination folder"
Commit: e43224c4d9cd79e81bd4c7a3dbff046692aa9d6c
https://github.com/scummvm/scummvm/commit/e43224c4d9cd79e81bd4c7a3dbff046692aa9d6c
Author: eientei (einstein95 at users.noreply.github.com)
Date: 2022-06-16T13:59:50+02:00
Commit Message:
DEVTOOLS: Format with `black`
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index bdddf065560..7c125357758 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -104,15 +104,17 @@ def decode_macjapanese(text: ByteString) -> str:
lo = next(i_text, None)
if lo is None:
print(f"WARNING: Mac Japanese sequence missing second byte 0x{hi:02x}")
- return text.decode('mac-roman')
- hi_key = f'{hi:02x}'
+ return text.decode("mac-roman")
+ hi_key = f"{hi:02x}"
lo_key = lo - 0x40
if lo_key < 0:
print(f"WARNING: second byte out of range 0x{lo:02x}")
- return text.decode('mac-roman')
+ return text.decode("mac-roman")
elif decode_map.get(hi_key) is None or decode_map[hi_key][lo_key] is None:
- print(f"WARNING: No mapping for MacJapanese sequence 0x{hi_key}{lo:02x}")
- return text.decode('mac-roman')
+ print(
+ f"WARNING: No mapping for MacJapanese sequence 0x{hi_key}{lo:02x}"
+ )
+ return text.decode("mac-roman")
assert_tmp = decode_map[hi_key][lo_key]
assert assert_tmp # mypy assert
res += assert_tmp
@@ -279,16 +281,18 @@ def extract_volume(args: argparse.Namespace) -> int:
print(f"Loading {source_volume} ...")
vol = machfs.Volume()
- with source_volume.open(mode='rb') as f:
+ with source_volume.open(mode="rb") as f:
f.seek(0x200)
- if f.read(4) == b'PM\0\0':
+ if f.read(4) == b"PM\0\0":
partition_num = 1
- partition_type = ''
- while partition_type != 'Apple_HFS':
- num_partitions, partition_start, partition_size = unpack('>III', f.read(12))
+ partition_type = ""
+ while partition_type != "Apple_HFS":
+ num_partitions, partition_start, partition_size = unpack(
+ ">III", f.read(12)
+ )
f.seek(32, 1)
- partition_type = f.read(32).decode('ascii').strip('\0')
- if partition_num <= num_partitions and partition_type != 'Apple_HFS':
+ partition_type = f.read(32).decode("ascii").strip("\0")
+ if partition_num <= num_partitions and partition_type != "Apple_HFS":
# Move onto the next partition
partition_num += 1
f.seek(partition_num * 0x200 + 4)
@@ -325,7 +329,7 @@ def extract_volume(args: argparse.Namespace) -> int:
upath.write_bytes(obj.data)
elif obj.rsrc:
- upath.write_bytes(file_to_macbin(obj, hpath[-1].encode('mac_roman')))
+ upath.write_bytes(file_to_macbin(obj, hpath[-1].encode("mac_roman")))
elif not obj.data and not obj.rsrc:
upath.touch()
@@ -336,16 +340,23 @@ def extract_volume(args: argparse.Namespace) -> int:
if len(hpath) > 1:
for i in range(len(hpath), 0, -1):
parent_folder_modtime = vol.get(hpath[:i]).mddate - 2082844800
- os.utime(Path(*(upath.parts[:i])), (parent_folder_modtime, parent_folder_modtime))
+ os.utime(
+ Path(*(upath.parts[:i])),
+ (parent_folder_modtime, parent_folder_modtime),
+ )
return 0
-def punyencode_paths(paths: List[Path], verbose: bool = False, source_encoding: str = None) -> int:
+def punyencode_paths(
+ paths: List[Path], verbose: bool = False, source_encoding: str = None
+) -> int:
"""Rename filepaths to their punyencoded names"""
count = 0
for path in paths:
if source_encoding is not None:
- new_name = punyencode(demojibake_hfs_bytestring(bytes(path.name, "utf8"), source_encoding))
+ new_name = punyencode(
+ demojibake_hfs_bytestring(bytes(path.name, "utf8"), source_encoding)
+ )
else:
new_name = punyencode(path.name)
if path.stem != new_name:
@@ -376,8 +387,8 @@ def demojibake_hfs_bytestring(s: ByteString, encoding: str):
# macOS renders paths as NFD, but to correctly translate
# this back to the original MacRoman, we first have to
# renormalize it to NFC.
- unicodedata.normalize('NFC', s.decode('utf8')).encode('macroman'),
- encoding
+ unicodedata.normalize("NFC", s.decode("utf8")).encode("macroman"),
+ encoding,
)
@@ -395,7 +406,9 @@ def punyencode_arg(args: argparse.Namespace) -> int:
return 0
-def punyencode_dir(directory: Path, verbose: bool = False, source_encoding: str = None) -> int:
+def punyencode_dir(
+ directory: Path, verbose: bool = False, source_encoding: str = None
+) -> int:
"""
Recursively punyencode all directory and filenames
@@ -482,7 +495,9 @@ def collect_forks(args: argparse.Namespace) -> int:
(info.st_mtime, info.st_mtime),
)
if punify:
- count_renames = punyencode_dir(directory, verbose=True, source_encoding=args.source_encoding)
+ count_renames = punyencode_dir(
+ directory, verbose=True, source_encoding=args.source_encoding
+ )
print(f"Macbinary {count_resources}, Renamed {count_renames} files")
return 0
@@ -583,9 +598,7 @@ def test_decode_mac_japanese():
b"QuickTime\xfe \x89\xb9\x90F\x91\xce\x89\x9e\x95\\",
"QuickTime⢠é³è²å¯¾å¿è¡¨",
],
- [
- b"Asant\x8e", "Asanté"
- ]
+ [b"Asant\x8e", "Asanté"],
]
for input, expected in checks:
assert decode_macjapanese(input) == expected
@@ -626,9 +639,12 @@ def test_decode_name():
["Jönssonligan går på djupet.exe", "xn--Jnssonligan gr p djupet.exe-glcd70c"],
["Jönssonligan.exe", "xn--Jnssonligan.exe-8sb"],
["G3ãã©ã«ã", "xn--G3-3g4axdtexf"],
- ["Where \\ Do <you> Want / To: G* ? ;Unless=nowhere,or|\"(everything)/\":*|\\?%<>,;=", "xn--Where Do you Want To G ;Unless=nowhere,or(everything),;=-5baedgdcbtamaaaaaaaaa99woa3wnnmb82aqb71ekb9g3c1f1cyb7bx6rfcv2pxa"],
+ [
+ 'Where \\ Do <you> Want / To: G* ? ;Unless=nowhere,or|"(everything)/":*|\\?%<>,;=',
+ "xn--Where Do you Want To G ;Unless=nowhere,or(everything),;=-5baedgdcbtamaaaaaaaaa99woa3wnnmb82aqb71ekb9g3c1f1cyb7bx6rfcv2pxa",
+ ],
["Buried in Timeェ Demo", "xn--Buried in Time Demo-yp97h"],
- ["ã±ãããPPC", "xn--PPC-873bpbxa3l"]
+ ["ã±ãããPPC", "xn--PPC-873bpbxa3l"],
]
for input, output in checks:
assert punyencode(input) == output
@@ -642,7 +658,7 @@ def test_needs_punyencoding():
["ããããã¤(Power PC)", False],
["ends_with_dot .", True],
["ends_with_space ", True],
- ["Big[test]", False]
+ ["Big[test]", False],
]
for input, expected in checks:
assert needs_punyencoding(input) == expected
More information about the Scummvm-git-logs
mailing list