blob: 54265faaa2152da25feec2a4dbee8e4c6897fac6 [file] [log] [blame]
Jack Jansen58fc91f2002-12-17 23:28:24 +00001"""macfs - Pure Python module designed to be backward compatible with
2macfs and MACFS.
3"""
4import sys
5
6# First step: ensure we also emulate the MACFS module, which contained
7# all the constants
8
9sys.modules['MACFS'] = sys.modules[__name__]
10
11# Import all those constants
12import Carbon.Files
13from Carbon.Folder import FindFolder
14
15# For some obscure historical reason these are here too:
16READ = 1
17WRITE = 2
18smAllScripts = -3
19
20import Carbon.File
21
22class FSSpec(Carbon.File.FSSpec):
23 def as_FSRef(self):
24 return FSRef(self)
25
26 def NewAlias(self, src=None):
27 if src is None:
28 src = FSSpec((0,0,''))
29 return self.NewAlias(src)
30
31 def GetCreatorType(self):
32 finfo = self.FSpGetFInfo()
33 return finfo[1], finfo[0]
34
35 def SetCreatorType(self, ctor, tp):
36 finfo = self.FSpGetFInfo()
37 finfo = (tp, ctor) + finfo[2:]
38 self.FSpSetFInfo(finfo)
39
40 def GetFInfo(self):
41 return self.FSpGetFInfo()
42
43 def SetFInfo(self, info):
44 return self.FSpSetFInfo(info)
45
46 def GetDates(self):
47 raise NotImplementedError, "FSSpec.GetDates no longer implemented"
48
49 def SetDates(self, *dates):
50 raise NotImplementedError, "FSSpec.SetDates no longer implemented"
51
52class FSRef(Carbon.File.FSRef):
53 def as_FSSpec(self):
54 return FSSpec(self)
55
56class Alias(Carbon.File.Alias):
57
58 def Resolve(self, src=None):
59 if src is None:
60 src = FSSpec((0, 0, ''))
61 return self.ResolveAlias(src)
62
63 def GetInfo(self, index):
64 return self.GetAliasInfo(index)
65
66 def Update(self, *args):
67 raise NotImplementedError, "Alias.Update not yet implemented"
68
69class FInfo:
70 pass
71
72FSSpecType = FSSpec
73FSRefType = FSRef
74AliasType = Alias
75FInfoType = FInfo
76
77def ResolveAliasFile(fss, chain=1):
78 return Carbon.Files.ResolveAliasFile(fss, chain)
79
80def RawFSSpec(data):
81 return FSSpec(rawdata=data)
82
83def RawAlias(data):
84 return Alias(rawdata=data)
85
86def FindApplication(*args):
87 raise NotImplementedError, "FindApplication no longer implemented"
88
89def NewAliasMinimalFromFullPath(path):
90 return Carbon.Files.NewAliasMinimalFromFullPath(path, '', '')