MCPcopy Create free account
hub / github.com/PerroEngine/Perro / load_dlc_static_binary

Function load_dlc_static_binary

perro_source/io_stack/perro_io/src/asset_io.rs:505–527  ·  view source on GitHub ↗
(dlc: &str, path: &str)

Source from the content-addressed store, hash-verified

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.
528pub fn load_asset(path: &str) -> io::Result<Vec<u8>> {
529 load_asset_cow(path).map(Cow::into_owned)
530}

Callers 1

load_assetFunction · 0.85

Calls 6

string_to_u64Function · 0.85
is_nullMethod · 0.80
to_vecMethod · 0.80
lookupFunction · 0.50
getMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected