Jack Jansen | 58fc91f | 2002-12-17 23:28:24 +0000 | [diff] [blame^] | 1 | """macfs - Pure Python module designed to be backward compatible with |
| 2 | macfs and MACFS. |
| 3 | """ |
| 4 | import sys |
| 5 | |
| 6 | # First step: ensure we also emulate the MACFS module, which contained |
| 7 | # all the constants |
| 8 | |
| 9 | sys.modules['MACFS'] = sys.modules[__name__] |
| 10 | |
| 11 | # Import all those constants |
| 12 | import Carbon.Files |
| 13 | from Carbon.Folder import FindFolder |
| 14 | |
| 15 | # For some obscure historical reason these are here too: |
| 16 | READ = 1 |
| 17 | WRITE = 2 |
| 18 | smAllScripts = -3 |
| 19 | |
| 20 | import Carbon.File |
| 21 | |
| 22 | class 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 | |
| 52 | class FSRef(Carbon.File.FSRef): |
| 53 | def as_FSSpec(self): |
| 54 | return FSSpec(self) |
| 55 | |
| 56 | class 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 | |
| 69 | class FInfo: |
| 70 | pass |
| 71 | |
| 72 | FSSpecType = FSSpec |
| 73 | FSRefType = FSRef |
| 74 | AliasType = Alias |
| 75 | FInfoType = FInfo |
| 76 | |
| 77 | def ResolveAliasFile(fss, chain=1): |
| 78 | return Carbon.Files.ResolveAliasFile(fss, chain) |
| 79 | |
| 80 | def RawFSSpec(data): |
| 81 | return FSSpec(rawdata=data) |
| 82 | |
| 83 | def RawAlias(data): |
| 84 | return Alias(rawdata=data) |
| 85 | |
| 86 | def FindApplication(*args): |
| 87 | raise NotImplementedError, "FindApplication no longer implemented" |
| 88 | |
| 89 | def NewAliasMinimalFromFullPath(path): |
| 90 | return Carbon.Files.NewAliasMinimalFromFullPath(path, '', '') |