summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-12-17 23:28:24 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-12-17 23:28:24 (GMT)
commit58fc91f9471f04a2826e62943542252d2b37f106 (patch)
tree5bc5fec4169014498aba5179daab925a04282a84 /Mac
parent3ebf56c60f07cd53b1199c604f1f6d3dd4427513 (diff)
downloadcpython-58fc91f9471f04a2826e62943542252d2b37f106.zip
cpython-58fc91f9471f04a2826e62943542252d2b37f106.tar.gz
cpython-58fc91f9471f04a2826e62943542252d2b37f106.tar.bz2
This module will shortly replace the builtin module macfs. It is not
complete yet, but it should work. It will be finished (and renamed) shortly.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Lib/newmacfs.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/Mac/Lib/newmacfs.py b/Mac/Lib/newmacfs.py
new file mode 100644
index 0000000..54265fa
--- /dev/null
+++ b/Mac/Lib/newmacfs.py
@@ -0,0 +1,90 @@
+"""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