pub fn get_files(
_sk_info: &Option<Rc<RefCell<SkInfo>>>,
dir: PathBuf,
file_extensions: &Vec<String>,
show_sub_dirs: bool,
) -> Vec<PathEntry>
Expand description
Read the files and eventually the sub directory of a given directory
_sk_info
- The SkInfo smart pointerdir
- The directory to read.file_extensions
- The file extensions to filter by.show_other_dirs
- If true, the sub directories will be shown.
Returns a vector of PathEntry.
ยงExamples
use stereokit_rust::tools::os_api::{get_files, PathEntry};
let sk_info = Some(sk.get_sk_info_clone());
let mut file_found = false;
let mut dir_found = false;
let exts = vec![".png".into(), ".jpg".into(), ".jpeg".into()];
let mut asset_sub_dir = std::path::PathBuf::new();
asset_sub_dir.push("assets/textures");
for file in get_files(&sk_info, asset_sub_dir, &exts, true) {
println!("--- {:?}", file);
match file {
PathEntry::File(file) => {
if file.into_string().unwrap_or_default()
.ends_with("log_viewer.jpeg") { file_found = true }
}
PathEntry::Dir(dir) => {
if dir.into_string().unwrap_or_default()
.ends_with("water") { dir_found = true }
}
}
}
assert!(file_found);
assert!(dir_found);