Home | History | Annotate | Download | only in misc
      1 from __future__ import print_function, division, absolute_import
      2 from fontTools.misc.py23 import *
      3 import sys
      4 try:
      5 	import MacOS
      6 except ImportError:
      7 	MacOS = None
      8 from .py23 import *
      9 
     10 def _reverseString(s):
     11 	s = list(s)
     12 	s.reverse()
     13 	return strjoin(s)
     14 
     15 
     16 def 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 
     29 def 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