#NEWLINE# def callback( self , r ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# r . file . size #NEWLINE# #UNINDENT# except KeyboardInterrupt as e : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( not r . size ) : #NEWLINE# #INDENT# size = ( r . file . size - r . offset ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# size = r . size #NEWLINE# #UNINDENT# if ( r . valid and r . extract and r . display and ( ( not self . max_count ) or ( self . extraction_count < self . max_count ) ) ) : #NEWLINE# #INDENT# if ( not binwalk . core . common . has_key ( self . output , r . file . path ) ) : #NEWLINE# #INDENT# self . output [ r . file . path ] = ExtractInfo ( ) #NEWLINE# #UNINDENT# binwalk . core . common . debug ( ( 'Extractor callback for %s @%d [%s]' % ( r . file . name , r . offset , r . description ) ) ) #NEWLINE# ( extraction_directory , dd_file , scan_extracted_files ) = self . extract ( r . offset , r . description , r . file . path , size , r . name ) #NEWLINE# if ( extraction_directory and dd_file ) : #NEWLINE# #INDENT# self . extraction_count += 1 #NEWLINE# dd_file_path = os . path . join ( extraction_directory , dd_file ) #NEWLINE# self . output [ r . file . path ] . carved [ r . offset ] = dd_file_path #NEWLINE# self . output [ r . file . path ] . extracted [ r . offset ] = [ ] #NEWLINE# directory_listing = set ( os . listdir ( extraction_directory ) ) #NEWLINE# if ( not has_key ( self . last_directory_listing , extraction_directory ) ) : #NEWLINE# #INDENT# self . last_directory_listing [ extraction_directory ] = set ( ) #NEWLINE# #UNINDENT# for f in directory_listing . difference ( self . last_directory_listing [ extraction_directory ] ) : #NEWLINE# #INDENT# file_path = os . path . join ( extraction_directory , f ) #NEWLINE# real_file_path = os . path . realpath ( file_path ) #NEWLINE# self . result ( description = file_path , display = False ) #NEWLINE# if ( real_file_path != dd_file_path ) : #NEWLINE# #INDENT# self . output [ r . file . path ] . extracted [ r . offset ] . append ( real_file_path ) #NEWLINE# #UNINDENT# if ( self . matryoshka and ( file_path != dd_file_path ) and scan_extracted_files and ( self . directory in real_file_path ) ) : #NEWLINE# #INDENT# if ( len ( real_file_path . split ( self . directory ) [ 1 ] . split ( os . path . sep ) ) <= self . matryoshka ) : #NEWLINE# #INDENT# if os . path . isdir ( file_path ) : #NEWLINE# #INDENT# for ( root , dirs , files ) in os . walk ( file_path ) : #NEWLINE# #INDENT# for f in files : #NEWLINE# #INDENT# full_path = os . path . join ( root , f ) #NEWLINE# self . add_pending ( full_path ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . add_pending ( file_path ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# self . last_directory_listing [ extraction_directory ] = directory_listing