ruwebframe 0.1.0

A brief description of your crate.
Documentation
use std::fs::File;
use std::io;
use std::io::Read;
use std::path::Path;
use tokio::io::AsyncReadExt;
use walkdir::{DirEntry, WalkDir};
use crate::rulog::rulog;

pub 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()
}
pub fn list_all_files_rs(dir: &str) -> Vec<String> {
    let allfiles=list_all_files(dir);
    let mut files=Vec::new();
    for file in allfiles {

        rulog::info(file.to_str().unwrap() );
            if file.extension().and_then(|s| s.to_str()) == Some("rs") {
                //println!("{}", file.display());
                files.push(file.display().to_string());
            }

    }
    files
}

pub fn is_rs(f:std::path::PathBuf)->bool{
    return  f.extension().and_then(|s| s.to_str()) == Some("rs")
}

pub  fn read_file(file_name :&str) -> Result<String, io::Error> {
    let mut file = File::open(file_name);  // ? 运算符:出错时直接返回 Err
    let mut contents = String::new();
    file?.read_to_string(&mut contents);       // 同上
    Ok(contents)
}
pub fn check_file_exist(pathf:String) -> bool {  // 例如: ./src/rupage/page/pageresult_init.rs
    Path::new(&pathf).exists()                  // 检查文件是否存在

}