bolt/utils/
fs_utils.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::ffi::OsString;
use std::fs;
use std::io;
use std::path::Path;

pub fn read_file_tree(path: &Path) -> io::Result<Vec<OsString>> {
    let mut entries: Vec<OsString> = vec![];
    if path.is_dir() {
        entries = fs::read_dir(path)?
            .map(|res| res.map(|e| e.file_name()))
            .collect::<Result<Vec<_>, io::Error>>()?;

        entries.sort()
    }
    Ok(entries)
}