INNER CODE UNIT · Python
scan_file_for_sentinel
ArcSurge/Termius-Pro-zh_CN · lang.py:34
def scan_file_for_sentinel(file_path, chunk_size=1024 * 1024):
"""流式扫描文件是否包含熔丝哨兵字符串"""
tail = b""
try:
with open(file_path, "rb") as file:
while True:
chunk = file.read(chunk_size)
if not chunk:
return False
if FUSE_SENTINEL in tail + chunk:
return True
tail = chunk[-(len(FUSE_SENTINEL) - 1):]
except OSError:
return False
def is_macos():
"""检测是否为 macOS 系统"""