mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-22 03:59:36 +00:00
Rewrite project from Python to Rust and add Windows/MacOS supports
This commit is contained in:
17
src/utils/fs.rs
Normal file
17
src/utils/fs.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn check_dir(dir: Option<&str>) -> io::Result<Vec<String>> {
|
||||
let path: PathBuf = match dir {
|
||||
None | Some(".") | Some("./") => std::env::current_dir()?,
|
||||
Some(value) => std::env::current_dir()?.join(value),
|
||||
};
|
||||
|
||||
let mut items = Vec::new();
|
||||
for entry in std::fs::read_dir(path)? {
|
||||
let entry = entry?;
|
||||
items.push(entry.file_name().to_string_lossy().to_string());
|
||||
}
|
||||
|
||||
Ok(items)
|
||||
}
|
||||
Reference in New Issue
Block a user