summaryrefslogtreecommitdiffstats
path: root/src/walk/unix.rs
blob: 51d370a5036b2012ccc71f3623b12ddba43b65e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::os::unix::fs::MetadataExt;

use super::UniqueID;

pub fn generate_unique_id(metadata: &std::fs::Metadata) -> Option<UniqueID> {
    // If the entry has more than one hard link, generate
    // a unique ID consisting of device and inode in order
    // not to count this entry twice.
    if metadata.is_file() && metadata.nlink() > 1 {
        Some(UniqueID(metadata.dev(), metadata.ino()))
    } else {
        None
    }
}