Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
def get_ifilter_for_file(filename, log=log):
    """
    Deal with structured storage file if possible.
    See http://msdn2.microsoft.com/en-us/library/aa380369.aspx
    """

    if pythoncom.StgIsStorageFile(filename):
        storage_init_flags = STGM_READ | STGM_SHARE_DENY_WRITE
        stg = pythoncom.StgOpenStorage(filename, None, storage_init_flags)
        try:
            filt = ifilter.BindIFilterFromStorage(stg)
        except pythoncom.com_error, e:
            if e[0] == -2147467262:
                filt = load_ifilter(filename, log=log)
            else:
                raise