blob: 57d158c2869132d112ae804c2f21f989005b9bd4 [file] [log] [blame]
jvr45d1f3b2008-03-01 11:34:54 +00001import sys
2try:
3 import MacOS
4except ImportError:
5 MacOS = None
6
7def _reverseString(s):
8 s = list(s)
9 s.reverse()
10 return "".join(s)
11
12
13def getMacCreatorAndType(path):
14 if MacOS is not None:
15 fileCreator, fileType = MacOS.GetCreatorAndType(path)
16 if sys.byteorder == "little":
17 # work around bug in MacOS.GetCreatorAndType() on intel:
18 # http://bugs.python.org/issue1594
19 fileCreator = _reverseString(fileCreator)
20 fileType = _reverseString(fileType)
21 return fileCreator, fileType
22 else:
23 return None, None
24
25
26def setMacCreatorAndType(path, fileCreator, fileType):
27 if MacOS is not None:
28 if sys.byteorder == "little":
29 # work around bug in MacOS.SetCreatorAndType() on intel:
30 # http://bugs.python.org/issue1594
31 fileCreator = _reverseString(fileCreator)
32 fileType = _reverseString(fileType)
33 MacOS.SetCreatorAndType(path, fileCreator, fileType)