def _bind_to_filter(self, fileName):
"""
See if the file is a structured storage file or a normal file
and then return an ifilter interface by calling the appropriate bind/load function
"""
if pythoncom.StgIsStorageFile(fileName):
self.stg = pythoncom.StgOpenStorage(fileName, None, storagecon.STGM_READ | storagecon.STGM_SHARE_DENY_WRITE)
try:
self.f = ifilter.BindIFilterFromStorage(self.stg)
except pythoncom.com_error, e:
if e[0] == -2147467262: # 0x80004002: # no interface, try the load interface (this happens for some MSoft files)
self.f = ifilter.LoadIFilter(fileName)
else:
raise
else:
self.f = ifilter.LoadIFilter(fileName)
self.stg = None
评论列表
文章目录