diff options
-rw-r--r-- | headers.c | 3 | ||||
-rw-r--r-- | muttlib.c | 29 | ||||
-rw-r--r-- | protos.h | 1 | ||||
-rw-r--r-- | send.c | 18 |
4 files changed, 34 insertions, 17 deletions
@@ -70,7 +70,8 @@ void mutt_edit_headers (const char *editor, return; } - mtime = st.st_mtime; + mtime = mutt_decrease_mtime (path, &st); + mutt_edit_file (editor, path); stat (path, &st); if (mtime == st.st_mtime) @@ -40,6 +40,9 @@ #include <errno.h> #include <sys/stat.h> #include <fcntl.h> +#include <time.h> +#include <sys/types.h> +#include <utime.h> BODY *mutt_new_body (void) { @@ -1255,3 +1258,29 @@ void mutt_buffer_add (BUFFER* buf, const char* s, size_t len) buf->dptr += len; *(buf->dptr) = '\0'; } + +/* Decrease a file's modification time by 1 second */ + +time_t mutt_decrease_mtime (const char *f, struct stat *st) +{ + struct utimbuf utim; + struct stat _st; + time_t mtime; + + if (!st) + { + if (stat (f, &_st) == -1) + return -1; + st = &_st; + } + + if ((mtime = st->st_mtime) == time (NULL)) + { + mtime -= 1; + utim.actime = mtime; + utim.modtime = mtime; + utime (f, &utim); + } + + return mtime; +} @@ -106,6 +106,7 @@ HEADER *mutt_dup_header (HEADER *); ATTACHPTR **mutt_gen_attach_list (BODY *, int, ATTACHPTR **, short *, short *, int, int); +time_t mutt_decrease_mtime (const char *, struct stat *); time_t mutt_local_tz (time_t); time_t mutt_mktime (struct tm *, int); time_t mutt_parse_date (const char *, HEADER *); @@ -1276,22 +1276,8 @@ ci_send_message (int flags, /* send mode */ else if (! (flags & SENDBATCH)) { struct stat st; - time_t mtime; - struct utimbuf utim; - - stat (msg->content->filename, &st); - mtime = st.st_mtime; - if (mtime == time (NULL)) - { - /* Decrease the file's modification time by 1 second so we are sure - * to find out if the `editor' program changes it in less than 1 second. - */ - mtime -= 1; - utim.actime = mtime; - utim.modtime = mtime; - utime (msg->content->filename, &utim); - } - + time_t mtime = mutt_decrease_mtime (msg->content->filename, NULL); + mutt_update_encoding (msg->content); /* If the this isn't a text message, look for a mailcap edit command */ |