MCPcopy Create free account
hub / github.com/agent0ai/agent-zero / is_binary

Function is_binary

plugins/_text_editor/helpers/file_ops.py:24–31  ·  view source on GitHub ↗

Detect binary file by checking for null bytes.

(path: str)

Source from the content-addressed store, hash-verified

22# ------------------------------------------------------------------
23
24def is_binary(path: str) -> bool:
25 """Detect binary file by checking for null bytes."""
26 try:
27 with open(path, "rb") as f:
28 chunk = f.read(_BINARY_PEEK)
29 return b"\x00" in chunk
30 except OSError:
31 return False
32
33
34# ------------------------------------------------------------------

Callers 1

read_fileFunction · 0.85

Calls 2

openFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected