File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020from __future__ import absolute_import
2121
2222import re
23- import binascii
23+ import sys
2424import mmap
25- from functools import wraps
25+ import binascii
2626import logging
27+ from functools import wraps
2728
2829import Evtx .Views as e_views
2930from .Nodes import RootNode
@@ -218,16 +219,26 @@ def current_chunk(self):
218219 ofs += (self .current_chunk_number () * 0x10000 )
219220 return ChunkHeader (self ._buf , ofs )
220221
221- def chunks (self ):
222+ def chunks (self , include_inactive = False ):
222223 """
223224 @return A generator that yields the chunks of the log file
224225 starting with the first chunk, which is always found directly
225- after the FileHeader, and continuing to the end of the file.
226+ after the FileHeader.
227+
228+ If `include_inactive` is set to true, enumerate chunks beyond those
229+ declared in the file header (and may therefore be corrupt).
226230 """
231+ if include_inactive :
232+ chunk_count = sys .maxint
233+ else :
234+ chunk_count = self .chunk_count ()
235+
236+ i = 0
227237 ofs = self ._offset + self .header_chunk_size ()
228- while ofs + 0x10000 <= len (self ._buf ):
238+ while ofs + 0x10000 <= len (self ._buf ) and i < chunk_count :
229239 yield ChunkHeader (self ._buf , ofs )
230240 ofs += 0x10000
241+ i += 1
231242
232243 def get_record (self , record_num ):
233244 """
You can’t perform that action at this time.
0 commit comments