diff options
| author | Quentin Carbonneaux | 2014-08-11 10:57:00 -0400 |
|---|---|---|
| committer | Quentin Carbonneaux | 2014-08-11 10:57:00 -0400 |
| commit | 7669a65209ef6d5b631ebaf7b710a1022678f657 (patch) | |
| tree | b689c2b87e27ba4ba9e9809223b2cdcfd6839ab8 | |
| parent | c744cad5c532757c9707a40b827ff936826e8a34 (diff) | |
remember revision of files written
| -rw-r--r-- | edit.h | 3 | ||||
| -rw-r--r-- | exec.c | 8 |
2 files changed, 7 insertions, 4 deletions
@@ -28,7 +28,8 @@ struct ebuf { Log *redo; Mark *ml; /* buffer marks */ char *path; /* file path */ - time_t mtime; /* last mtime when written/read */ + time_t ftime; /* last mtime when written/read */ + unsigned frev; /* last revision written */ }; EBuf *eb_new(void); @@ -115,7 +115,8 @@ ex_get(EBuf *eb, char *file) close(fd); stat(file1, &st); eb->path = file1; - eb->mtime = st.st_mtime; + eb->ftime = st.st_mtime; + eb->frev = eb_revision(eb); return 0; } @@ -142,7 +143,7 @@ ex_put(EBuf *eb, char *file) return 1; } if (stat(file, &st) != -1) - if (st.st_mtime > eb->mtime) { + if (st.st_mtime > eb->ftime) { errstr = "file changed on disk"; return 1; } @@ -161,7 +162,8 @@ ex_put(EBuf *eb, char *file) } if (strcmp(eb->path, file) == 0) { stat(file, &st); - eb->mtime = st.st_mtime; + eb->ftime = st.st_mtime; + eb->frev = eb_revision(eb); } return 0; } |
