[Scummvm-git-logs] scummvm master -> 0e0aef020117303ff0d14a715ae75102ee40f046
rvanlaar
roland at rolandvanlaar.nl
Mon Aug 9 13:54:17 UTC 2021
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c586311c26 DEVTOOLS: COMPANION: add development info helptext
8ddb3aec3a DEVTOOLS: COMPANION: remove superfluous statement
4d00111acf DEVTOOLS: COMPANION: hfs dump use existing dir
66568ca700 DEVTOOLS: COMPANION: Improve helptext
0e0aef0201 DEVTOOLS: COMPANION: add macbinary mode
Commit: c586311c26e921fc3b5d93664856d085f4462c20
https://github.com/scummvm/scummvm/commit/c586311c26e921fc3b5d93664856d085f4462c20
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2021-08-09T15:54:05+02:00
Commit Message:
DEVTOOLS: COMPANION: add development info helptext
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index 3ae3aee453..b232843a2b 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -1,8 +1,12 @@
#!/usr/bin/env python3
#
# prerequisites: pip3 install machfs
+#
+# Development information:
# This file contains tests. They can be run with:
# $ pytest dumper-companion.py
+#
+# Code is formatted with blacks
import argparse
import io
@@ -19,7 +23,7 @@ def file_to_macbin(f: machfs.File, name: str, encoding: str) -> bytes:
newFlags = f.flags & 8
macbin = pack(
">xB63s4s4sBxHHHBxIIIIHB14xIHBB",
- len(name),
+ len(name), # TODO: shouldn't this be the encoded file length?
name.encode(encoding),
f.type,
f.creator,
@@ -30,8 +34,8 @@ def file_to_macbin(f: machfs.File, name: str, encoding: str) -> bytes:
f.locked,
len(f.data),
len(f.rsrc),
- f.crdate,
- f.mddate,
+ f.crdate, # TODO: dates are wrong, investigate
+ f.mddate, # TODO: dates are wrong, investigate
0,
newFlags,
0,
Commit: 8ddb3aec3a47f0b0cb465c474750940731e88869
https://github.com/scummvm/scummvm/commit/8ddb3aec3a47f0b0cb465c474750940731e88869
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2021-08-09T15:54:05+02:00
Commit Message:
DEVTOOLS: COMPANION: remove superfluous statement
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index b232843a2b..a24edd30ac 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -64,7 +64,7 @@ def escape_string(s: str) -> str:
new_name += "\x81" + chr(0x80 + ord(char))
else:
new_name += char
- return "".join(new_name)
+ return new_name
def punyencode(orig: str, encoding: str = "mac_roman") -> str:
Commit: 4d00111acfc3c2717cbb9f63becb71d67ae19547
https://github.com/scummvm/scummvm/commit/4d00111acfc3c2717cbb9f63becb71d67ae19547
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2021-08-09T15:54:05+02:00
Commit Message:
DEVTOOLS: COMPANION: hfs dump use existing dir
Don't complain when the directory to write to already exists.
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index a24edd30ac..345c044967 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -106,7 +106,7 @@ def extract_volume(args: argparse.Namespace) -> None:
vol = machfs.Volume()
vol.read(source_volume.read_bytes())
- destination_dir.mkdir(parents=True)
+ destination_dir.mkdir(parents=True, exist_ok=True)
for hpath, obj in vol.iter_paths():
upath = generate_punyencoded_path(destination_dir, encoding, hpath)
Commit: 66568ca700caa344934ccbedf0f181b40c5a3ebb
https://github.com/scummvm/scummvm/commit/66568ca700caa344934ccbedf0f181b40c5a3ebb
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2021-08-09T15:54:05+02:00
Commit Message:
DEVTOOLS: COMPANION: Improve helptext
Make it clear that punyencoding of stdin is supported.
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index 345c044967..46881061e8 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -147,7 +147,7 @@ def generate_parser() -> argparse.ArgumentParser:
)
parser_iso.set_defaults(func=extract_volume)
- parser_str = subparsers.add_parser("str", help="Punyencode strings")
+ parser_str = subparsers.add_parser("str", help="Punyencode strings or standard in")
parser_str.add_argument(
"--stdin", action="store_true", help="Convert stdin to punycode"
)
Commit: 0e0aef020117303ff0d14a715ae75102ee40f046
https://github.com/scummvm/scummvm/commit/0e0aef020117303ff0d14a715ae75102ee40f046
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2021-08-09T15:54:05+02:00
Commit Message:
DEVTOOLS: COMPANION: add macbinary mode
`dumper-companion.py mac [--punycode] directory` will recursively look
for resourceforks and encode them inplace as macbinary.
When `--punycode` is enabled it will encode filenames in punycode.
This is a MacOS only feature.
Changed paths:
devtools/dumper-companion.py
diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index 46881061e8..af8b5831d5 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -10,6 +10,8 @@
import argparse
import io
+import os
+import sys
from binascii import crc_hqx
from pathlib import Path
from struct import pack
@@ -121,6 +123,62 @@ def extract_volume(args: argparse.Namespace) -> None:
upath.write_bytes(file)
+def has_resource_fork(dirpath: str, filename: str) -> bool:
+ """
+ Check if file has a resource fork
+
+ Ease of compatibility between macOS and linux
+ """
+ filepath = os.path.join(dirpath, filename)
+ return os.path.exists(os.path.join(filepath, "..namedfork/rsrc"))
+
+
+def collect_forks(args: argparse.Namespace) -> None:
+ """
+ Collect resource forks and move them to a macbinary file
+
+ - combine them with the data fork when it's available
+ - punyencode the filename when requested
+ """
+ directory: Path = args.dir
+ punify: bool = args.punycode
+ count_resources = 0
+ count_renames = 0
+ for dirpath, _, filenames in os.walk(directory):
+ for filename in filenames:
+ if has_resource_fork(dirpath, filename):
+ print(f"Resource in {filename}")
+ count_resources += 1
+ data_filename = filename
+ to_filename = data_filename + ".bin"
+ if punify:
+ tmp = punyencode(to_filename)
+ if tmp != to_filename:
+ print(f"Renamed {to_filename} to {tmp}")
+ count_renames += 1
+ to_filename = tmp
+ with open(os.path.join(dirpath, filename), "rb") as rsrc:
+ file = machfs.File()
+ file.rsrc = rsrc.read()
+ with open(os.path.join(dirpath, data_filename), "rb") as data:
+ file.data = data.read()
+ with open(os.path.join(dirpath, to_filename), "wb") as to_file:
+ to_file.write(
+ file_to_macbin(file, to_filename, encoding="mac_roman")
+ )
+ elif punify:
+ punified_filename = punyencode(filename)
+ if punified_filename != filename:
+ print(f"Renamed {to_filename} to {punified_filename}")
+ count_renames += 1
+ os.rename(
+ os.path.join(dirpath, tmp),
+ os.path.join(dirpath, punified_filename),
+ )
+
+ print(f"Macbinary {count_resources}, Renamed {count_renames} files")
+
+
def generate_parser() -> argparse.ArgumentParser:
"""
Generate the parser
@@ -160,6 +218,19 @@ def generate_parser() -> argparse.ArgumentParser:
)
parser_str.set_defaults(func=encode_string)
+ if sys.platform == "darwin":
+ parser_macbinary = subparsers.add_parser(
+ "mac",
+ help="MacOS only: Operate in MacBinary encoding mode. Recursively encode all resource forks in the current directory",
+ )
+ parser_macbinary.add_argument(
+ "--punycode", action="store_true", help="encode pathnames into punycode"
+ )
+ parser_macbinary.add_argument(
+ "dir", metavar="directory", type=Path, help="input directory"
+ )
+ parser_macbinary.set_defaults(func=collect_forks)
+
return parser
More information about the Scummvm-git-logs
mailing list