1from __future__ import print_function, division, absolute_import 2from fontTools.misc.py23 import * 3import sys 4try: 5 import MacOS 6except ImportError: 7 MacOS = None 8from .py23 import * 9 10def _reverseString(s): 11 s = list(s) 12 s.reverse() 13 return strjoin(s) 14 15 16def getMacCreatorAndType(path): 17 if MacOS is not None: 18 fileCreator, fileType = MacOS.GetCreatorAndType(path) 19 if sys.byteorder == "little": 20 # work around bug in MacOS.GetCreatorAndType() on intel: 21 # http://bugs.python.org/issue1594 22 fileCreator = _reverseString(fileCreator) 23 fileType = _reverseString(fileType) 24 return fileCreator, fileType 25 else: 26 return None, None 27 28 29def setMacCreatorAndType(path, fileCreator, fileType): 30 if MacOS is not None: 31 if sys.byteorder == "little": 32 # work around bug in MacOS.SetCreatorAndType() on intel: 33 # http://bugs.python.org/issue1594 34 fileCreator = _reverseString(fileCreator) 35 fileType = _reverseString(fileType) 36 MacOS.SetCreatorAndType(path, fileCreator, fileType) 37