def __init__(self, parsed, offset, is_ghost=False, ads=''): index = parsed['record_n'] ads_suffix = ':' + ads if ads != '' else ads if ads != '': index = unicode(index) + ads_suffix attrs = parsed['attributes'] filenames = attrs['$FILE_NAME'] datas = attrs.get('$DATA', []) size = None for attr in datas: if attr['name'] == ads: if 'real_size' in attr: size = attr['real_size'] elif not attr['non_resident']: size = attr['content_size'] break filtered = [ f for f in filenames if f.has_key('content') and f['content'] is not None and f['content']['name_length'] > 0 and f['content']['name'] is not None ] name = best_name([ (f['content']['namespace'], f['content']['name'] + ads_suffix) for f in filtered ]) hasname = name is not None if not hasname: name = 'File_%s' % index is_dir = (parsed['flags'] & 0x02) > 0 and not len(ads) is_del = (parsed['flags'] & 0x01) == 0 File.__init__(self, index, name, size, is_dir, is_del, is_ghost) # Additional attributes if hasname: first = filtered[0]['content'] parent_id = first['parent_entry'] File.set_parent(self, parent_id) File.set_offset(self, offset) File.set_mac( self, first['modification_time'], first['access_time'], first['creation_time'] ) self.ads = ads
def __init__(self, parsed, offset, is_ghost=False, ads=''): index = parsed['record_n'] ads_suffix = ':' + ads if ads != '' else ads if ads != '': index = unicode(index) + ads_suffix attrs = parsed['attributes'] filenames = attrs['$FILE_NAME'] datas = attrs['$DATA'] if '$DATA' in attrs else [] size = None for attr in datas: if attr['name'] == ads: if 'real_size' in attr: size = attr['real_size'] elif not attr['non_resident']: size = attr['content_size'] break filtered = [ f for f in filenames if f.has_key('content') and f['content'] is not None and f['content']['name_length'] > 0 and f['content']['name'] is not None ] name = best_name([ (f['content']['namespace'], f['content']['name'] + ads_suffix) for f in filtered ]) hasname = name is not None if not hasname: name = 'File_%s' % index is_dir = (parsed['flags'] & 0x02) > 0 and not len(ads) is_del = (parsed['flags'] & 0x01) == 0 File.__init__(self, index, name, size, is_dir, is_del, is_ghost) # Additional attributes if hasname: first = filtered[0]['content'] parent_id = first['parent_entry'] File.set_parent(self, parent_id) File.set_offset(self, offset) File.set_mac( self, first['modification_time'], first['access_time'], first['creation_time'] ) self.ads = ads