- if (stat (SSDATA (filename), &st) < 0)
- {
- /* If the file doesn't exist now and didn't exist before,
- we say that it isn't modified, provided the error is a tame one. */
- if (errno == ENOENT || errno == EACCES || errno == ENOTDIR)
- st.st_mtime = -1;
- else
- st.st_mtime = 0;
- }
- if ((st.st_mtime == b->modtime
- /* If both are positive, accept them if they are off by one second. */
- || (st.st_mtime > 0 && b->modtime > 0
- && (st.st_mtime - 1 == b->modtime
- || st.st_mtime == b->modtime - 1)))
+ mtime = (stat (SSDATA (filename), &st) == 0
+ ? get_stat_mtime (&st)
+ : time_error_value (errno));
+ if ((EMACS_TIME_EQ (mtime, b->modtime)
+ /* If both exist, accept them if they are off by one second. */
+ || (EMACS_TIME_VALID_P (mtime) && EMACS_TIME_VALID_P (b->modtime)
+ && ((diff = (EMACS_TIME_LT (mtime, b->modtime)
+ ? sub_emacs_time (b->modtime, mtime)
+ : sub_emacs_time (mtime, b->modtime))),
+ EMACS_TIME_LE (diff, make_emacs_time (1, 0)))))