refactor(files): move file IO, watcher and link helpers into files.rs

This commit is contained in:
2026-11-06 07:23:51 +08:00
parent d78d1aa722
commit 1208386452
3 changed files with 487 additions and 459 deletions

18
src/testutil.rs Normal file
View File

@@ -0,0 +1,18 @@
//! Test-only helpers shared by the module test suites.
use std::fs;
use std::path::PathBuf;
use std::time::{SystemTime, UNIX_EPOCH};
/// Create a unique scratch directory under the platform temp dir (the test
/// runner points TEMP/TMP at `target\tmp`).
pub fn temp_dir(name: &str) -> PathBuf {
let unique = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_nanos();
let dir =
std::env::temp_dir().join(format!("md-preview-{name}-{}-{unique}", std::process::id()));
fs::create_dir_all(&dir).unwrap();
dir
}