2002-12-17 19:28:24 -04:00
|
|
|
"""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
|
2002-12-19 19:26:07 -04:00
|
|
|
from Carbon.Files import *
|
|
|
|
from Carbon.Folders import *
|
|
|
|
# Another method:
|
2002-12-17 19:28:24 -04:00
|
|
|
from Carbon.Folder import FindFolder
|
|
|
|
|
|
|
|
# For some obscure historical reason these are here too:
|
|
|
|
READ = 1
|
|
|
|
WRITE = 2
|
|
|
|
smAllScripts = -3
|
|
|
|
|
2002-12-19 19:26:07 -04:00
|
|
|
|
2002-12-17 19:28:24 -04:00
|
|
|
import Carbon.File
|
2002-12-19 19:26:07 -04:00
|
|
|
# The old name of the error object:
|
|
|
|
error = Carbon.File.Error
|
2002-12-17 19:28:24 -04:00
|
|
|
|
|
|
|
class FSSpec(Carbon.File.FSSpec):
|
2002-12-19 19:26:07 -04:00
|
|
|
def as_fsref(self):
|
2002-12-17 19:28:24 -04:00
|
|
|
return FSRef(self)
|
|
|
|
|
|
|
|
def NewAlias(self, src=None):
|
2002-12-19 19:26:07 -04:00
|
|
|
return Alias(Carbon.File.NewAlias(src, self))
|
2002-12-17 19:28:24 -04:00
|
|
|
|
|
|
|
def GetCreatorType(self):
|
|
|
|
finfo = self.FSpGetFInfo()
|
2002-12-19 19:26:07 -04:00
|
|
|
return finfo.Creator, finfo.Type
|
2002-12-17 19:28:24 -04:00
|
|
|
|
|
|
|
def SetCreatorType(self, ctor, tp):
|
|
|
|
finfo = self.FSpGetFInfo()
|
2002-12-19 19:26:07 -04:00
|
|
|
finfo.Creator = ctor
|
|
|
|
finfo.Type = tp
|
2002-12-17 19:28:24 -04:00
|
|
|
self.FSpSetFInfo(finfo)
|
|
|
|
|
|
|
|
def GetFInfo(self):
|
|
|
|
return self.FSpGetFInfo()
|
|
|
|
|
|
|
|
def SetFInfo(self, info):
|
|
|
|
return self.FSpSetFInfo(info)
|
|
|
|
|
|
|
|
def GetDates(self):
|
2002-12-19 19:26:07 -04:00
|
|
|
import os
|
|
|
|
statb = os.stat(self.as_pathname())
|
|
|
|
return statb.st_ctime, statb.st_mtime, 0
|
2002-12-17 19:28:24 -04:00
|
|
|
|
|
|
|
def SetDates(self, *dates):
|
2002-12-19 19:26:07 -04:00
|
|
|
print "FSSpec.SetDates no longer implemented"
|
2002-12-17 19:28:24 -04:00
|
|
|
|
|
|
|
class FSRef(Carbon.File.FSRef):
|
2002-12-19 19:26:07 -04:00
|
|
|
def as_fsspec(self):
|
2002-12-17 19:28:24 -04:00
|
|
|
return FSSpec(self)
|
|
|
|
|
|
|
|
class Alias(Carbon.File.Alias):
|
|
|
|
|
|
|
|
def GetInfo(self, index):
|
|
|
|
return self.GetAliasInfo(index)
|
|
|
|
|
|
|
|
def Update(self, *args):
|
2002-12-19 19:26:07 -04:00
|
|
|
print "Alias.Update not yet implemented"
|
|
|
|
|
|
|
|
def Resolve(self, src=None):
|
2002-12-26 16:46:54 -04:00
|
|
|
fss, changed = self.ResolveAlias(src)
|
|
|
|
return FSSpec(fss), changed
|
2002-12-19 19:26:07 -04:00
|
|
|
|
|
|
|
from Carbon.File import FInfo
|
2002-12-17 19:28:24 -04:00
|
|
|
|
|
|
|
FSSpecType = FSSpec
|
|
|
|
FSRefType = FSRef
|
|
|
|
AliasType = Alias
|
|
|
|
FInfoType = FInfo
|
|
|
|
|
|
|
|
def ResolveAliasFile(fss, chain=1):
|
2002-12-26 16:46:54 -04:00
|
|
|
fss, isdir, isalias = Carbon.File.ResolveAliasFile(fss, chain)
|
|
|
|
return FSSpec(fss), isdir, isalias
|
2002-12-17 19:28:24 -04:00
|
|
|
|
|
|
|
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):
|
2002-12-26 16:46:54 -04:00
|
|
|
return Alias(Carbon.File.NewAliasMinimalFromFullPath(path, '', ''))
|
2002-12-19 19:26:07 -04:00
|
|
|
|
|
|
|
# Finally, install nav services
|
|
|
|
import macfsn
|