#windows-file #windows #locking #file-lock #find #process-file #locksmith

filelocksmith

Detect what processes are locking a file or folder on Windows

5 releases

0.1.4 Sep 27, 2024
0.1.3 Aug 3, 2024
0.1.2 Aug 3, 2024
0.1.1 Aug 3, 2024
0.1.0 Aug 2, 2024

#677 in Development tools

Download history 29/week @ 2024-10-06 27/week @ 2024-10-13 135/week @ 2024-10-20 108/week @ 2024-10-27 138/week @ 2024-11-03 173/week @ 2024-11-10 60/week @ 2024-11-17 193/week @ 2024-11-24 104/week @ 2024-12-01 6/week @ 2024-12-08

442 downloads per month

MIT license

51KB
1K SLoC

C++ 775 SLoC // 0.0% comments Visual Studio Project 214 SLoC Rust 72 SLoC

filelocksmith-rs

Version License Documentation

Reliably find and quit processes that are locking a file or folder on Windows. This is a difficult problem to solve on Windows, as the OS does not provide a built-in or straight-forward way to do this.

Additionally, unlike *nix, files and folders can not be deleted or moved while they are locked by a process.

This library wraps the FileLocksmith module from the Microsoft PowerToys project, which is written in C++.

Further documentation at https://docs.rs/filelocksmith

Installing

[dependencies]
filelocksmith = "0.1"

Usage

use filelocksmith::{find_processes_locking_path, quit_processes, pid_to_process_path};

let path = "C:\\path\\to\\file.txt";
let pids = find_processes_locking_path(path);

// print paths of processes locking the file
for pid in &pids {
   println!("[{}] {:?}", pid, pid_to_process_path(*pid));
}

// quit the processes locking the file
if quit_processes(pids) {
 println!("Processes quit successfully");
}

No runtime deps

~0–305KB

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy