(dlc: &str, path: &str)
| 503 | } else { |
| 504 | ResolvedPath::Disk(root.join(path)) |
| 505 | } |
| 506 | } |
| 507 | Some(ProjectRoot::PerroAssets { .. }) => { |
| 508 | if let Some(stripped) = path.strip_prefix("res://") { |
| 509 | if is_static_binary_path(stripped) { |
| 510 | // `path` already reads `res://<stripped>`: rebuilding it costs |
| 511 | // a format pass for an identical string. |
| 512 | ResolvedPath::StaticBinary(path.to_string()) |
| 513 | } else { |
| 514 | ResolvedPath::PerroAssets(format!("res/{}", stripped)) |
| 515 | } |
| 516 | } else { |
| 517 | ResolvedPath::PerroAssets(path.to_string()) |
| 518 | } |
| 519 | } |
| 520 | None => ResolvedPath::Disk(PathBuf::from(path)), |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | /// Load an asset fully into memory. |
| 525 | /// |
| 526 | /// Prefer [`load_asset_cow`] when the caller only reads the bytes: static |
| 527 | /// builds hand back the embedded slice instead of copying it. |
| 528 | pub fn load_asset(path: &str) -> io::Result<Vec<u8>> { |
| 529 | load_asset_cow(path).map(Cow::into_owned) |
| 530 | } |
no test coverage detected