From 4235e71accb07e1db42319480d3b8253c8451c61 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Thu, 19 Dec 2002 23:26:07 +0000 Subject: A replacement for the macfs extension module, implemented with normal (generated) Carbon module functionality. Not 100% complete yet, but at least the IDE doesn't crash on startup. --- Mac/Lib/macfs.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Mac/Lib/newmacfs.py | 90 ------------------------------------------------- 2 files changed, 96 insertions(+), 90 deletions(-) create mode 100644 Mac/Lib/macfs.py delete mode 100644 Mac/Lib/newmacfs.py diff --git a/Mac/Lib/macfs.py b/Mac/Lib/macfs.py new file mode 100644 index 0000000..8c3af52 --- /dev/null +++ b/Mac/Lib/macfs.py @@ -0,0 +1,96 @@ +"""macfs - Pure Python module designed to be backward compatible with +macfs and MACFS. +""" +import sys + +# First step: ensure we also emulate the MACFS module, which contained +# all the constants + +sys.modules['MACFS'] = sys.modules[__name__] + +# Import all those constants +from Carbon.Files import * +from Carbon.Folders import * +# Another method: +from Carbon.Folder import FindFolder + +# For some obscure historical reason these are here too: +READ = 1 +WRITE = 2 +smAllScripts = -3 + + +import Carbon.File +# The old name of the error object: +error = Carbon.File.Error + +class FSSpec(Carbon.File.FSSpec): + def as_fsref(self): + return FSRef(self) + + def NewAlias(self, src=None): + return Alias(Carbon.File.NewAlias(src, self)) + + def GetCreatorType(self): + finfo = self.FSpGetFInfo() + return finfo.Creator, finfo.Type + + def SetCreatorType(self, ctor, tp): + finfo = self.FSpGetFInfo() + finfo.Creator = ctor + finfo.Type = tp + self.FSpSetFInfo(finfo) + + def GetFInfo(self): + return self.FSpGetFInfo() + + def SetFInfo(self, info): + return self.FSpSetFInfo(info) + + def GetDates(self): + import os + statb = os.stat(self.as_pathname()) + return statb.st_ctime, statb.st_mtime, 0 + + def SetDates(self, *dates): + print "FSSpec.SetDates no longer implemented" + +class FSRef(Carbon.File.FSRef): + def as_fsspec(self): + return FSSpec(self) + +class Alias(Carbon.File.Alias): + + def GetInfo(self, index): + return self.GetAliasInfo(index) + + def Update(self, *args): + print "Alias.Update not yet implemented" + + def Resolve(self, src=None): + return self.ResolveAlias(src)[1:] + +from Carbon.File import FInfo + +FSSpecType = FSSpec +FSRefType = FSRef +AliasType = Alias +FInfoType = FInfo + +def ResolveAliasFile(fss, chain=1): + return Carbon.Files.ResolveAliasFile(fss, chain) + +def RawFSSpec(data): + return FSSpec(rawdata=data) + +def RawAlias(data): + return Alias(rawdata=data) + +def FindApplication(*args): + raise NotImplementedError, "FindApplication no longer implemented" + +def NewAliasMinimalFromFullPath(path): + return Carbon.Files.NewAliasMinimalFromFullPath(path, '', '') + +# Finally, install nav services +import macfsn \ No newline at end of file diff --git a/Mac/Lib/newmacfs.py b/Mac/Lib/newmacfs.py deleted file mode 100644 index 54265fa..0000000 --- a/Mac/Lib/newmacfs.py +++ /dev/null @@ -1,90 +0,0 @@ -"""macfs - Pure Python module designed to be backward compatible with -macfs and MACFS. -""" -import sys - -# First step: ensure we also emulate the MACFS module, which contained -# all the constants - -sys.modules['MACFS'] = sys.modules[__name__] - -# Import all those constants -import Carbon.Files -from Carbon.Folder import FindFolder - -# For some obscure historical reason these are here too: -READ = 1 -WRITE = 2 -smAllScripts = -3 - -import Carbon.File - -class FSSpec(Carbon.File.FSSpec): - def as_FSRef(self): - return FSRef(self) - - def NewAlias(self, src=None): - if src is None: - src = FSSpec((0,0,'')) - return self.NewAlias(src) - - def GetCreatorType(self): - finfo = self.FSpGetFInfo() - return finfo[1], finfo[0] - - def SetCreatorType(self, ctor, tp): - finfo = self.FSpGetFInfo() - finfo = (tp, ctor) + finfo[2:] - self.FSpSetFInfo(finfo) - - def GetFInfo(self): - return self.FSpGetFInfo() - - def SetFInfo(self, info): - return self.FSpSetFInfo(info) - - def GetDates(self): - raise NotImplementedError, "FSSpec.GetDates no longer implemented" - - def SetDates(self, *dates): - raise NotImplementedError, "FSSpec.SetDates no longer implemented" - -class FSRef(Carbon.File.FSRef): - def as_FSSpec(self): - return FSSpec(self) - -class Alias(Carbon.File.Alias): - - def Resolve(self, src=None): - if src is None: - src = FSSpec((0, 0, '')) - return self.ResolveAlias(src) - - def GetInfo(self, index): - return self.GetAliasInfo(index) - - def Update(self, *args): - raise NotImplementedError, "Alias.Update not yet implemented" - -class FInfo: - pass - -FSSpecType = FSSpec -FSRefType = FSRef -AliasType = Alias -FInfoType = FInfo - -def ResolveAliasFile(fss, chain=1): - return Carbon.Files.ResolveAliasFile(fss, chain) - -def RawFSSpec(data): - return FSSpec(rawdata=data) - -def RawAlias(data): - return Alias(rawdata=data) - -def FindApplication(*args): - raise NotImplementedError, "FindApplication no longer implemented" - -def NewAliasMinimalFromFullPath(path): - return Carbon.Files.NewAliasMinimalFromFullPath(path, '', '') \ No newline at end of file -- cgit v0.12