MCPcopy Create free account
hub / github.com/chatmail/core / read_file

Function read_file

src/tools.rs:484–499  ·  view source on GitHub ↗

Reads the file and returns its context as a byte vector.

(context: &Context, path: &Path)

Source from the content-addressed store, hash-verified

482
483/// Reads the file and returns its context as a byte vector.
484pub async fn read_file(context: &Context, path: &Path) -> Result<Vec<u8>> {
485 let path_abs = get_abs_path(context, path);
486
487 match fs::read(&path_abs).await {
488 Ok(bytes) => Ok(bytes),
489 Err(err) => {
490 warn!(
491 context,
492 "Cannot read \"{}\" or file is empty: {}",
493 path.display(),
494 err
495 );
496 Err(err.into())
497 }
498 }
499}
500
501pub async fn open_file(context: &Context, path: &Path) -> Result<fs::File> {
502 let path_abs = get_abs_path(context, path);

Callers 4

poke_eml_fileFunction · 0.85
cmdlineFunction · 0.85
import_secret_keyFunction · 0.85

Calls 1

get_abs_pathFunction · 0.85

Tested by

no test coverage detected