Skip to main content

geop_ops_model/parameters/
files.rs

1//! The files around a program, as a field picking one offers them: read
2//! through the runner running the program (see
3//! [`geop_core_program::workspace`]).
4
5use geop_core_editor::editing::FileEntry;
6use geop_core_program::runner::Runner;
7
8/// What a field picking a file `runner`'s program reads offers: every file
9/// it could name, sorted, those of the kind `kind` takes accepted. None,
10/// without files.
11pub fn file_choices(runner: &Runner, kind: impl Fn(&str) -> bool) -> Vec<FileEntry> {
12    let mut paths = runner.files();
13    paths.sort();
14    (paths.into_iter())
15        .map(|path| FileEntry {
16            accepted: kind(&path),
17            path,
18        })
19        .collect()
20}