- removed support for Python 2.2 on MacOS 10.2
- worked around a bug in GetCreatorType() on intel Macs
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@526 4cde692c-a291-49d1-8350-778aa11640f8
diff --git a/Lib/fontTools/misc/macCreatorType.py b/Lib/fontTools/misc/macCreatorType.py
new file mode 100644
index 0000000..57d158c
--- /dev/null
+++ b/Lib/fontTools/misc/macCreatorType.py
@@ -0,0 +1,33 @@
+import sys
+try:
+ import MacOS
+except ImportError:
+ MacOS = None
+
+def _reverseString(s):
+ s = list(s)
+ s.reverse()
+ return "".join(s)
+
+
+def getMacCreatorAndType(path):
+ if MacOS is not None:
+ fileCreator, fileType = MacOS.GetCreatorAndType(path)
+ if sys.byteorder == "little":
+ # work around bug in MacOS.GetCreatorAndType() on intel:
+ # http://bugs.python.org/issue1594
+ fileCreator = _reverseString(fileCreator)
+ fileType = _reverseString(fileType)
+ return fileCreator, fileType
+ else:
+ return None, None
+
+
+def setMacCreatorAndType(path, fileCreator, fileType):
+ if MacOS is not None:
+ if sys.byteorder == "little":
+ # work around bug in MacOS.SetCreatorAndType() on intel:
+ # http://bugs.python.org/issue1594
+ fileCreator = _reverseString(fileCreator)
+ fileType = _reverseString(fileType)
+ MacOS.SetCreatorAndType(path, fileCreator, fileType)