5 releases
| 0.2.3 | Aug 3, 2025 |
|---|---|
| 0.2.2 | Oct 25, 2024 |
| 0.2.1 | Aug 21, 2023 |
| 0.2.0 | Aug 20, 2023 |
| 0.1.0 | May 17, 2023 |
#1278 in Filesystem
351,597 downloads per month
Used in 260 crates
(4 directly)
11KB
143 lines
Utility for reading inode numbers (Linux, macOS) and file ids (Windows) that uniquely identify a file on a single computer.
Modern file systems assign a unique ID to each file. On Linux and macOS it is called an inode number,
on Windows it is called a file id or file index.
Together with the device id (Linux, macOS) or the volume serial number (Windows),
a file or directory can be uniquely identified on a single computer at a given time.
Keep in mind though, that IDs may be re-used at some point.
Example
let file = tempfile::NamedTempFile::new().unwrap();
let file_id = file_id::get_file_id(file.path()).unwrap();
println!("{file_id:?}");
Example (Windows Only)
let file = tempfile::NamedTempFile::new().unwrap();
let file_id = file_id::get_low_res_file_id(file.path()).unwrap();
println!("{file_id:?}");
let file_id = file_id::get_high_res_file_id(file.path()).unwrap();
println!("{file_id:?}");
File Id
A utility to read file IDs.
Modern file systems assign a unique ID to each file. On Linux and MacOS it is called an inode number, on Windows it is called file index.
Together with the device id, a file can be identified uniquely on a device at a given time.
Keep in mind though, that IDs may be re-used at some point.
Example
let file_id = file_id::get_file_id(path).unwrap();
println!("{file_id:?}");
Features
serdefor serde support, off by default
Dependencies
~0–12MB
~79K SLoC