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

Function load_asset

perro_source/io_stack/perro_io/src/asset_io.rs:388–413  ·  view source on GitHub ↗

Load an asset fully into memory

(path: &str)

Source from the content-addressed store, hash-verified

386 | Component::RootDir
387 | Component::Prefix(_) => {
388 return Err(io::Error::new(
389 io::ErrorKind::InvalidInput,
390 "asset path escapes root",
391 ));
392 }
393 }
394 }
395 Ok(())
396}
397
398fn validate_dlc_mount_name(name: &str) -> io::Result<()> {
399 if name.is_empty() || name == "." || name == ".." || name.contains(['/', '\\']) {
400 return Err(io::Error::new(
401 io::ErrorKind::InvalidInput,
402 "invalid dlc mount name",
403 ));
404 }
405 Ok(())
406}
407
408/// Resolve virtual path (res://foo/bar.png or user://save.dat) to actual location
409pub fn resolve_path(path: &str) -> ResolvedPath {
410 if validate_virtual_asset_path(path).is_err() {
411 return ResolvedPath::Disk(PathBuf::from(path));
412 }
413
414 let (project_root_opt, root_has_res_dir, demo_excluded) = {
415 let state = PROJECT_ASSET_STATE
416 .read()

Callers 15

load_bytesFunction · 0.85
existsFunction · 0.85
bench_static_asset_loadFunction · 0.85
load_post_texture_rgbaFunction · 0.85
load_shader_sourceFunction · 0.85
load_texture_rgbaFunction · 0.85
decode_gltf_textureFunction · 0.85
load_pmatFunction · 0.85
load_gltf_materialFunction · 0.85

Calls 9

load_web_user_assetFunction · 0.85
load_static_binaryFunction · 0.85
load_dlc_static_binaryFunction · 0.85
read_fileMethod · 0.80
resolve_pathFunction · 0.70
as_refMethod · 0.45
readMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected