update code

This commit is contained in:
lychang
2024-01-12 06:38:54 +08:00
parent 260fe25aaf
commit 89237f3522
3 changed files with 18 additions and 10 deletions

View File

@@ -18,6 +18,11 @@ pub(crate) fn write_file(path: &str, content: Bytes) -> Result<(), std::io::Erro
}
pub(crate) fn read_file_string(path: &str) -> Result<String, std::io::Error> {
let path = Path::new(path);
let folder_path = path.parent();
if !folder_path.unwrap().exists() {
fs::create_dir_all(folder_path.unwrap().as_os_str())?;
}
let mut file = File::open(path)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;