| 579 | } |
| 580 | let lookups = { |
| 581 | let state = PROJECT_ASSET_STATE |
| 582 | .read() |
| 583 | .expect("required value must be present"); |
| 584 | if state.demo || state.playtest { |
| 585 | // Let `resolve_path` own exclusion so the error text stays single-sourced. |
| 586 | return None; |
| 587 | } |
| 588 | match state.root.as_deref() { |
| 589 | Some(ProjectRoot::PerroAssets { |
| 590 | static_resource_lookups, |
| 591 | .. |
| 592 | }) => *static_resource_lookups, |
| 593 | _ => return None, |
| 594 | } |
| 595 | }; |
| 596 | Some(static_resource_slice(lookups, path)) |
| 597 | } |
| 598 | |
| 599 | fn load_resolved(resolved: ResolvedPath) -> io::Result<Vec<u8>> { |
| 600 | match resolved { |
| 601 | ResolvedPath::Excluded(path) => Err(io::Error::new( |
| 602 | io::ErrorKind::NotFound, |
| 603 | format!("asset `{path}` excluded from build"), |
| 604 | )), |
| 605 | ResolvedPath::Disk(pb) => fs::read(pb), |
| 606 | ResolvedPath::WebUserStorage(key) => load_web_user_asset(&key), |
| 607 | ResolvedPath::PerroAssets(virtual_path) => { |
| 608 | let archive = PROJECT_ASSET_STATE |
| 609 | .read() |
| 610 | .expect("required value must be present") |
| 611 | .archive |
| 612 | .clone(); |
| 613 | if let Some(archive) = archive { |
| 614 | archive.read_file(&virtual_path) |