Files
Blacksite/crates/scene/src/upgrade/io.rs
T

27 lines
698 B
Rust

use std::fs;
use std::path::{Path, PathBuf};
pub(super) fn collect_files(path: &Path, output: &mut Vec<PathBuf>) -> Result<(), String> {
if !path.exists() {
return Ok(());
}
for entry in fs::read_dir(path).map_err(|error| error.to_string())? {
let entry = entry.map_err(|error| error.to_string())?;
let path = entry.path();
if entry
.file_type()
.map_err(|error| error.to_string())?
.is_dir()
{
collect_files(&path, output)?;
} else {
output.push(path);
}
}
Ok(())
}
pub(super) fn normalize_text(text: &str) -> String {
text.trim().replace("\r\n", "\n")
}