Skip to content

Commit

Permalink
Fix/clean-up pathname management for the objdef dir read
Browse files Browse the repository at this point in the history
  • Loading branch information
rdaum committed Feb 15, 2025
1 parent c42d263 commit e117407
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/kernel/src/objdef/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ impl<'a> ObjectDefinitionLoader<'a> {
// Constant variables will go here.
let mut context = ObjFileContext::new();

// Collect all the file names, and if there's a "constants.moo" put that at the top to
// parse first.
// Collect all the file names,
let filenames: Vec<_> = dirpath
.read_dir()
.unwrap()
.filter(|e| e.as_ref().unwrap().path().extension().unwrap() == "moo")
.map(|e| e.unwrap().path())
.expect("Unable to open import directory")
.filter_map(|entry| entry.ok())
.filter_map(|e| e.path().is_file().then(|| e.path()))
.filter(|path| path.extension().map(|ext| ext == "moo").unwrap_or(false))
.collect();
// and if there's a "constants.moo" put that at the top to parse first
let constants_file = filenames
.iter()
.find(|f| f.file_name().unwrap() == "constants.moo");
Expand Down

0 comments on commit e117407

Please sign in to comment.