Function: verify-visited-file-modtime

verify-visited-file-modtime is a function defined in fileio.c.

Signature

(verify-visited-file-modtime &optional BUF)

Documentation

Return t if last mod time of BUF's visited file matches what BUF records.

This means that the file has not been changed since it was visited or saved. If BUF is omitted or nil, it defaults to the current buffer. See Info node (elisp)Modification Time for more details.

View in manual

Source Code

// Defined in /usr/src/emacs/src/fileio.c
{
  struct buffer *b = decode_buffer (buf);
  struct stat st;
  Lisp_Object handler;
  Lisp_Object filename;
  struct timespec mtime;

  if (!STRINGP (BVAR (b, filename))) return Qt;
  if (b->modtime.tv_nsec == UNKNOWN_MODTIME_NSECS) return Qt;

  /* If the file name has special constructs in it,
     call the corresponding file name handler.  */
  handler = Ffind_file_name_handler (BVAR (b, filename),
				     Qverify_visited_file_modtime);
  if (!NILP (handler))
    return calln (handler, Qverify_visited_file_modtime, buf);

  filename = ENCODE_FILE (BVAR (b, filename));
  mtime = (emacs_fstatat (AT_FDCWD, SSDATA (filename), &st, 0) == 0
	   ? get_stat_mtime (&st)
	   : time_error_value (errno));
  if (timespec_cmp (mtime, b->modtime) == 0
      && (b->modtime_size < 0
	  || st.st_size == b->modtime_size))
    return Qt;
  return Qnil;
}