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

Function write_file

src/tools.rs:465–481  ·  view source on GitHub ↗

Write a the given content to provided file path.

(
    context: &Context,
    path: &Path,
    buf: &[u8],
)

Source from the content-addressed store, hash-verified

463
464/// Write a the given content to provided file path.
465pub(crate) async fn write_file(
466 context: &Context,
467 path: &Path,
468 buf: &[u8],
469) -> Result<(), io::Error> {
470 let path_abs = get_abs_path(context, path);
471 fs::write(&path_abs, buf).await.map_err(|err| {
472 warn!(
473 context,
474 "Cannot write {} bytes to \"{}\": {}",
475 buf.len(),
476 path.display(),
477 err
478 );
479 err
480 })
481}
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>> {

Callers 1

export_key_to_asc_fileFunction · 0.85

Calls 1

get_abs_pathFunction · 0.85

Tested by

no test coverage detected