diff --git a/floss/main.py b/floss/main.py index 326deaa11..3e23d868b 100644 --- a/floss/main.py +++ b/floss/main.py @@ -537,7 +537,11 @@ def main(argv=None) -> int: # can throw away result later if not desired in output time0 = time() interim = time0 + static_strings = get_static_strings(sample, args.min_length) + if static_strings == []: + return 0 + static_runtime = get_runtime_diff(interim) lang_id = identify_language(sample, static_strings) diff --git a/floss/utils.py b/floss/utils.py index 106476804..895bd7c95 100644 --- a/floss/utils.py +++ b/floss/utils.py @@ -541,6 +541,11 @@ def get_static_strings(sample: Path, min_length: int) -> list: """ Returns list of static strings from the file which are above the minimum length """ + + if sample.stat().st_size == 0: + logger.warning("File is empty") + return [] + with sample.open("r") as f: if hasattr(mmap, "MAP_PRIVATE"): # unix