refactor: 删除部分多余的代码和注释

This commit is contained in:
mofeng-git
2026-05-01 17:31:04 +08:00
parent 74035f8e12
commit d8e7de74a6
165 changed files with 2960 additions and 9917 deletions

23
src/utils/fs.rs Normal file
View File

@@ -0,0 +1,23 @@
//! Small filesystem helpers.
use std::path::Path;
/// Read a UTF-8 file and trim surrounding whitespace.
pub fn read_trimmed(path: &Path) -> Option<String> {
std::fs::read_to_string(path)
.ok()
.map(|value| value.trim().to_string())
}
/// Sorted list of directory entry names (lossy exclusion on non-UTF8).
pub fn list_dir_names(path: &Path) -> Vec<String> {
let mut names = std::fs::read_dir(path)
.ok()
.into_iter()
.flatten()
.flatten()
.filter_map(|entry| entry.file_name().into_string().ok())
.collect::<Vec<_>>();
names.sort();
names
}