Skip to content

Commit 1b5f2bc

Browse files
committed
fix(file_utils): use pyperscan builtin file iteration when scanning whole file
1 parent f4ab9ef commit 1b5f2bc

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

unblob/file_utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import Iterator, List, Tuple, Union
1010

1111
from dissect.cstruct import cstruct
12-
from pyperscan import Scan
1312

1413
from .logging import format_hex
1514

@@ -255,9 +254,7 @@ def iterate_file(
255254

256255
def stream_scan(scanner, file: File):
257256
"""Scan the whole file by increment of DEFAULT_BUFSIZE using Hyperscan's streaming mode."""
258-
for i in range(0, file.size(), DEFAULT_BUFSIZE):
259-
if scanner.scan(file[i : i + DEFAULT_BUFSIZE]) == Scan.Terminate:
260-
break
257+
scanner.scan(file, DEFAULT_BUFSIZE)
261258

262259

263260
class StructParser:

0 commit comments

Comments
 (0)