[Scummvm-git-logs] scummvm master -> 0e69fb7e612118f353cadde8b3c3a2d822a7ac5d

sev- sev at scummvm.org
Thu Aug 12 17:37:13 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0e69fb7e61 DEVTOOLS: COMPANION: Use xattr module for creator/type extraction


Commit: 0e69fb7e612118f353cadde8b3c3a2d822a7ac5d
    https://github.com/scummvm/scummvm/commit/0e69fb7e612118f353cadde8b3c3a2d822a7ac5d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-08-12T19:36:58+02:00

Commit Message:
DEVTOOLS: COMPANION: Use xattr module for creator/type extraction

Changed paths:
    devtools/dumper-companion.py


diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index f0cbbd117b..36a5ea88fa 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -13,9 +13,16 @@ import io
 import os
 import sys
 import re
+if sys.platform == "darwin":
+    try:
+        import xattr
+    except ImportError:
+        print("xattr is required for the 'mac' mode to work\n")
+        pass
+
 from binascii import crc_hqx
 from pathlib import Path
-from struct import pack
+from struct import pack, unpack
 from typing import Any, List, Tuple
 
 import machfs
@@ -167,13 +174,13 @@ def collect_forks(args: argparse.Namespace) -> None:
                 file.mddate = 2082844800 + int(info.st_mtime)
 
                 # Get info on creator and type
-                tmp = os.popen("GetFileInfo \"" + os.path.join(dirpath, filename) + "\"").read()
-
-                groups = re.search(r"type: \"(.*)\"\ncreator: \"(.*)\"", tmp)
+                try:
+                    finderInfo = xattr.xattr(os.path.join(dirpath, filename))['com.apple.FinderInfo'][0:8]
+                except (IOError, OSError) as e:
+                    onError(e)
+                    return
 
-                # We may have here "\0\0\0\0"
-                file.type = groups.group(1).encode().decode('unicode-escape').encode()
-                file.creator = groups.group(2).encode().decode('unicode-escape').encode()
+                (file.type, file.creator) = unpack("4s4s", finderInfo)
 
                 with open(os.path.join(dirpath, resource_filename), "rb") as rsrc:
                     file.rsrc = rsrc.read()




More information about the Scummvm-git-logs mailing list