Write a the given content to provided file path.
(
context: &Context,
path: &Path,
buf: &[u8],
)
| 463 | |
| 464 | /// Write a the given content to provided file path. |
| 465 | pub(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. |
| 484 | pub async fn read_file(context: &Context, path: &Path) -> Result<Vec<u8>> { |
no test coverage detected