Load an asset fully into memory
(path: &str)
| 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 | |
| 398 | fn 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 |
| 409 | pub 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() |
no test coverage detected