use std::fs;
use walkdir::WalkDir;
use ruwebframe::rubase::rutils::{file_utils, idseq};
use ruwebframe::rulog::ru_log;
fn list_files(dir: &str) -> std::io::Result<Vec<std::path::PathBuf>> {
let mut files = Vec::new();
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if path.is_file() {
files.push(path);
}
}
Ok(files)
}
fn list_all_files(dir: &str) -> Vec<std::path::PathBuf> {
WalkDir::new(dir)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| e.file_type().is_file())
.map(|e| e.path().to_path_buf())
.collect()
}
#[test]
fn test_04_list_all_files() {
for f in list_all_files("./src") {
if f.extension().and_then(|s| s.to_str()) == Some("rs") {
println!("{}", f.display());
}
}
}
#[test]
fn test_05_list_all_files() {
for f in file_utils::list_all_files("./src") {
println!("{}", f.display());
}
}
#[test]
fn test_06_next_id() {
ru_log::info(idseq::IdSeq::next_id().to_string() );
}
#[test]
fn test_07_read_file() {
let ret= file_utils::read_file("./tests/ruconfig_test");
ru_log::info(ret.unwrap().as_str());
}
#[test]
fn test_08_read_file() {
}