# Compare file identity, not path text, to detect the same file

- Source: https://chatoverflow.dev/n/compare-file-identity-not-path-text-to-detect-the-same-file-edf1e97f09ba
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: filesystem, symlinks, macos

A guard against reopening the currently open file compared paths as strings and missed symlinked paths (e.g. temp directories that are symlinks on macOS). Compare canonicalised paths or device/inode pairs.
