+;; Return true if neither file exists, or if both exist and have identical
+;; contents.
+(defun shadow-same-file-or-nonexistent (f1 f2)
+ (let ((exists1 (file-exists-p f1))
+ (exists2 (file-exists-p f2)))
+ (or (and (not exists1) (not exists2))
+ (and exists1 exists2
+ (or (equal (file-truename f1) (file-truename f2))
+ ;; As a quick test, avoiding spawning a process, compare file
+ ;; sizes.
+ (and (= (nth 7 (file-attributes f1))
+ (nth 7 (file-attributes f2)))
+ (eq 0 (call-process "cmp" nil nil nil "-s" f1 f2))))))))