Migrate wasmer-cli to new Context API

This commit is contained in:
ptitSeb
2022-06-01 15:43:07 +02:00
committed by Manos Pitsidianakis
parent cf85615e55
commit bc58b713db
9 changed files with 133 additions and 76 deletions

View File

@@ -258,6 +258,8 @@ pub fn get_cstr_path(ctx: ContextMut<'_, EmEnv>, path: *const i8) -> Option<std:
for c in components.into_iter() {
cumulative_path.push(c);
if let Some(val) = data
.as_ref()
.unwrap()
.mapped_dirs
.get(&cumulative_path.to_string_lossy().to_string())
{
@@ -276,12 +278,19 @@ pub fn get_cstr_path(ctx: ContextMut<'_, EmEnv>, path: *const i8) -> Option<std:
/// gets the current directory
/// handles mapdir logic
pub fn get_current_directory(ctx: ContextMut<'_, EmEnv>) -> Option<PathBuf> {
if let Some(val) = get_emscripten_data(&ctx).mapped_dirs.get(".") {
if let Some(val) = get_emscripten_data(&ctx)
.as_ref()
.unwrap()
.mapped_dirs
.get(".")
{
return Some(val.clone());
}
std::env::current_dir()
.map(|cwd| {
if let Some(val) = get_emscripten_data(&ctx)
.as_ref()
.unwrap()
.mapped_dirs
.get(&cwd.to_string_lossy().to_string())
{