Reads the file and returns its context as a byte vector.
(context: &Context, path: &Path)
| 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>> { |
| 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 | |
| 501 | pub async fn open_file(context: &Context, path: &Path) -> Result<fs::File> { |
| 502 | let path_abs = get_abs_path(context, path); |
no test coverage detected