emulator: imports work relatively to file being assembled (set cwd)

This commit is contained in:
2025-06-19 16:35:00 +01:00
parent b5ce5e0011
commit 6f834025ed
3 changed files with 16 additions and 7 deletions
+8 -3
View File
@@ -146,7 +146,7 @@ impl Editor {
}
if let Some(path) = FileDialog::new()
.add_filter("damn simple files", &["dsa", "dsb", "dsc", "dsd"])
.add_filter("Assembly Files or Binaries", &["dsa", "dsb"])
.add_filter("all", &["*"])
.set_directory(&work_dir)
.save_file()
@@ -169,17 +169,22 @@ impl Editor {
});
if let Some(path) = FileDialog::new()
.add_filter("damn simple files", &["dsa", "dsb", "dsc", "dsd"])
.add_filter("Assembly Files or Binaries", &["dsa", "dsb"])
.add_filter("all", &["*"])
.set_directory(&work_dir)
.pick_file()
{
if let Ok(contents) = std::fs::read_to_string(&path) {
self.path = Some(path);
self.path = Some(path.clone());
self.text.clone_from(&contents);
self.buffer = contents;
self.unsaved = false;
}
std::env::set_current_dir(
path.parent().expect("A file should be in a directory!"),
)
.expect("ERROR: Failed to set current working directory.");
}
}