| Crates.io | wholock |
| lib.rs | wholock |
| version | 0.0.1 |
| created_at | 2025-02-25 15:34:48.414974+00 |
| updated_at | 2025-02-25 15:34:48.414974+00 |
| description | A rust crate helps you to find out who's locking your file on windows |
| homepage | |
| repository | https://github.com/Hellager/wholock-rs |
| max_upload_size | |
| id | 1569251 |
| size | 65,857 |
Read this in other languages: English | δΈζ
Windows file locking diagnostics toolkit with surgical precision. Identify processes locking files and safely release resources.
This is basically a Rust implementation of File Locksmith and for now its in a very early version.
Add to Cargo.toml:
[dependencies]
wholock = "0.0.1"
Requires Windows 10+ and Rust 1.70+
use wholock::{who_locks_file, WholockError};
fn main() -> Result<(), WholockError> {
let target = r"C:\critical\database.lock";
let processes = who_locks_file(target)?;
processes.iter().for_each(|p| {
println!("π Process {} (PID: {}) locks:", p.process_name, p.pid);
p.locked_file.iter().for_each(|f| println!(" - {}", f));
});
Ok(())
}
use wholock::{unlock_file, WholockError};
fn release_lock(pid: u32) -> Result<(), WholockError> {
match unlock_file(pid) {
Ok(_) => println!("β
Successfully terminated PID {}", pid),
Err(e) => eprintln!("β Error terminating process: {}", e),
}
Ok(())
}
use wholock::ProcessInfo;
use tokio::time::{interval, Duration};
async fn monitor_locks(path: &str) -> wholock::WholockResult<()> {
let mut interval = interval(Duration::from_secs(30));
loop {
interval.tick().await;
let locks = who_locks_file(path)?;
if !locks.is_empty() {
send_alert(&locks).await?;
}
}
}
async fn send_alert(processes: &[ProcessInfo]) -> wholock::WholockResult<()> {
// Implement custom notification logic
Ok(())
}
| Component | Requirement |
|---|---|
| OS Version | Windows 10+ |
| Rust Toolchain | 1.70+ (MSRV) |
| Security Policy | SeDebugPrivilege enabled |
# Clone with submodules
git clone --recurse-submodules https://github.com/Hellager/wholock-rs.git
# Build with Windows SDK
cargo build --features=win32
# Run tests (admin required)
cargo test -- --test-threads=1
feat/[feature-name] / fix/[issue-number]For urgent issues, create a GitHub Issue with:
winver)Distributed under the LICENSE-MIT License. See LICENSE for more information.
Developed with π¦ by @Hellager