summaryrefslogtreecommitdiff
path: root/src/file.rs
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-07-07 22:45:22 -0400
committerMica White <botahamec@outlook.com>2026-07-07 22:45:22 -0400
commita9977e7fabeb06a6f21824cc4a41b36ea39f6799 (patch)
tree86b586fa8b8a312b2e4d2e5800260fc98430b91b /src/file.rs
parent07018cb37b278dbd73c864a662454f1cf9d33457 (diff)
Full host environment
Diffstat (limited to 'src/file.rs')
-rw-r--r--src/file.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/file.rs b/src/file.rs
index 20fdd68..9b9888c 100644
--- a/src/file.rs
+++ b/src/file.rs
@@ -2,7 +2,7 @@ use std::{ffi::OsStr, path::Path};
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
-use smol::{Task, block_on, unblock};
+use smol::{Task, unblock};
use crate::{
scene::{ResourceRequirements, Scene, scene_id_by_name},
@@ -63,7 +63,10 @@ fn normalize_game_manifest(manifest: TomlGameManifest) -> std::io::Result<GameMa
.into_iter()
.map(|script| match script {
TomlScript::Wasm { name, path } => {
- scripts.push(ScriptDeclaration::Wasm { path });
+ scripts.push(ScriptDeclaration::Wasm {
+ name: name.clone(),
+ path,
+ });
(name, scripts.len() - 1)
}
})
@@ -159,21 +162,8 @@ impl FileManager {
Ok(self.cache.get(&path).unwrap())
}
- pub fn get_loaded_file(&mut self, path: Box<Path>) -> Option<std::io::Result<&FileData>> {
- if let Some(task) = self.active_tasks.get(path.as_ref())
- && task.is_finished()
- {
- let data = match block_on(self.active_tasks.remove(&path).unwrap()) {
- Ok(data) => data,
- Err(e) => return Some(Err(e)),
- };
- self.cache.entry(path.clone()).insert_entry(data);
- Some(Ok(self.cache.get(&path).unwrap()))
- } else if let Some(data) = self.cache.get(&path) {
- Some(Ok(data))
- } else {
- None
- }
+ pub fn get_cached_file(&self, path: &Path) -> Option<&FileData> {
+ self.cache.get(path)
}
pub fn start_loading_file(&mut self, path: impl AsRef<Path>, wasm_compiler: &wasmi::Engine) {