Function: file-has-changed-p

file-has-changed-p is a byte-compiled function defined in compat-29.el.

Signature

(file-has-changed-p FILE &optional TAG)

Documentation

[Compatibility function for file-has-changed-p, defined in Emacs 29.1. See
(compat) Emacs 29.1' for more details.]

Return non-nil if FILE has changed. The size and modification time of FILE are compared to the size and modification time of the same FILE during a previous invocation of file-has-changed-p. Thus, the first invocation of file-has-changed-p always returns non-nil when FILE exists. The optional argument TAG, which must be a symbol, can be used to limit the comparison to invocations with identical tags; it can be the symbol of the calling function, for example.

Aliases

org-file-has-changed-p

Source Code

;; Defined in ~/.emacs.d/elpa/compat-30.1.0.1/compat-29.el
(compat-defun file-has-changed-p (file &optional tag) ;; <compat-tests:file-has-changed-p>
  "Return non-nil if FILE has changed.
The size and modification time of FILE are compared to the size
and modification time of the same FILE during a previous
invocation of `file-has-changed-p'.  Thus, the first invocation
of `file-has-changed-p' always returns non-nil when FILE exists.
The optional argument TAG, which must be a symbol, can be used to
limit the comparison to invocations with identical tags; it can be
the symbol of the calling function, for example."
  (let* ((file (directory-file-name (expand-file-name file)))
         (remote-file-name-inhibit-cache t)
         (fileattr (file-attributes file 'integer))
         (attr (and fileattr
                    (cons (file-attribute-size fileattr)
                          (file-attribute-modification-time fileattr))))
         (sym (concat (symbol-name tag) "@" file))
         (cachedattr (gethash sym file-has-changed-p--hash-table)))
    (unless (equal attr cachedattr)
      (puthash sym attr file-has-changed-p--hash-table))))