MCPcopy Index your code
hub / github.com/agent0ai/agent-zero / _read_file_binary_impl

Function _read_file_binary_impl

helpers/rfc_files.py:346–362  ·  view source on GitHub ↗

Implementation function to read a file in binary mode. Returns base64 encoded content for RFC transport.

(file_path: str)

Source from the content-addressed store, hash-verified

344# =====================================================
345
346def _read_file_binary_impl(file_path: str) -> str:
347 """
348 Implementation function to read a file in binary mode.
349 Returns base64 encoded content for RFC transport.
350 """
351 if not os.path.exists(file_path):
352 raise FileNotFoundError(f"File not found: {file_path}")
353
354 if not os.path.isfile(file_path):
355 raise Exception(f"Path is not a file: {file_path}")
356
357 try:
358 with open(file_path, 'rb') as file:
359 content = file.read()
360 return base64.b64encode(content).decode('utf-8')
361 except Exception as e:
362 raise Exception(f"Failed to read file {file_path}: {str(e)}")
363
364
365def _write_file_binary_impl(file_path: str, b64_content: str) -> bool:

Callers

nothing calls this directly

Calls 3

openFunction · 0.50
readMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected