diff options
Diffstat (limited to 'src/file.rs')
| -rw-r--r-- | src/file.rs | 24 |
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) { |
