This page describes the purpose, problem domain, and high-level architecture of WindowsClear (愚公移盘). It is scoped to what the tool is and why it exists. For how to run or build it, see Getting Started. For technical design details, see Architecture.
WindowsClear is a Windows utility that frees C-drive space by migrating large AppData folders to a secondary disk and replacing them with NTFS directory junctions (mklink /J). From the application's perspective, no path changes — the junction makes the moved folder transparently accessible at its original location.
The core problem it solves:
%LOCALAPPDATA%and%APPDATA%accumulate gigabytes of application cache and data over time. Partitioning tools require reboots and risk data loss. WindowsClear migrates those folders non-destructively and keeps software fully functional.
Sources: README.md24-27 README_EN.md8-9
| Feature | Description |
|---|---|
| Intelligent scan | Parallel directory sizing across %LOCALAPPDATA% and %APPDATA%; shows only folders that exceed 10% of their parent's size |
| Seamless migration | Moves folder to target disk, then places a junction at the original path so software needs no reconfiguration |
| Process guard | Uses the Windows Restart Manager API to detect and optionally terminate processes locking files before migration |
| Rollback | If migration fails mid-flight, the mover restores the original directory from a backup |
| Smart cache | Scan results are stored in scan_cache.json; repeated scans with no filesystem changes return instantly |
| Byte-level progress | Real-time transfer speed and ETA during migration |
| Pause / Resume | An Arc<AtomicBool> pause signal lets the user pause file copy at any point |
| Bilingual UI | Chinese / English toggle backed by core::i18n |
Sources: README.md37-47 README_EN.md11-22
RmStartSession, GetDriveTypeW, GetDiskFreeSpaceExW, mklink /J)WindowsClear.exe (internal Cargo package name: cpan_mover)Sources: README.md51-52 README_EN.md24
The following diagram maps feature areas to their corresponding source modules.
Diagram: Features → Code Modules
Sources: README.md37-47
WindowsClear is a single process (WindowsClear.exe). The GUI runs on the main thread via eframe/egui. All heavy work (scanning, file copy, process management) runs on spawned OS threads. Results are communicated back to the GUI through an AppEvent channel (std::sync::mpsc).
Diagram: Runtime threads and communication
Sources: README.md37-47 README_EN.md8-22
| Module | File | Role |
|---|---|---|
App | src/main.rs | All UI state, eframe::App::update loop, event dispatch |
AppEvent | src/main.rs | Enum of all worker → GUI messages |
core::scanner | src/core/scanner.rs | Parallel directory sizing, cache read/write |
core::mover | src/core/mover.rs | File transfer strategies, junction creation, rollback |
core::proc_mgr | src/core/proc_mgr.rs | Restart Manager queries, process termination |
core::config | src/core/config.rs | AppConfig / ScanSource persistence, drive detection |
core::i18n | src/core/i18n.rs | t() translation lookup, global OnceLock<Mutex<I18n>> |
core::logger | src/core/logger.rs | log() timestamped file writes, OnceLock<Mutex<File>> |
For detailed documentation of each module, see Core Systems.
Sources: README.md43-46
WindowsClear depends on several Windows-only APIs. These are accessed through the windows crate and via std::process::Command for junction creation.
| API | Used by | Purpose |
|---|---|---|
RmStartSession / RmGetList | core::proc_mgr | Identify processes locking a file |
OpenProcess / TerminateProcess | core::proc_mgr | Kill a locking process by PID |
GetDriveTypeW | core::config | Identify fixed disks for target selection |
GetDiskFreeSpaceExW | core::config | Pick the non-C drive with the most free space |
mklink /J (via cmd.exe) | core::mover | Create NTFS directory junction at original path |
Sources: README.md61-63 README_EN.md31-33
WindowsClear is released under the MIT License.
Sources: README.md98-99