pub fn link_count(path: &Path) -> Result<u32, Error>Expand description
Get the link count for a file.
Returns the number of hard links pointing to the file. A regular file without hardlinks has a link count of 1. A link count > 1 indicates the file has hard links.
§Fail-Closed Behavior
If the link count cannot be determined (e.g., permission denied, file
cannot be opened), this function returns Err. Callers should treat
errors as potential hardlinks for security (fail closed).
§Platform Behavior
- Unix: Uses
metadata.nlink()viaMetadataExt - Windows: Uses
GetFileInformationByHandleWin32 API to getnNumberOfLinks
§Arguments
path- The path to check. Must be a regular file (not a directory).
§Returns
Ok(n)- The file hasnhard linksErr(e)- Could not determine link count (treat as potential hardlink)