save (ctrl-s function) normally does not save if no changes are made. However if file timestamp has changed since opening (by someone else) prompt user to decide what to do (save or not)

This commit is contained in:
stefan schippers 2023-06-04 10:16:17 +02:00
parent c708050baf
commit 6d08202a5d
1 changed files with 23 additions and 12 deletions

View File

@ -450,7 +450,18 @@ const char *get_file_path(char *f)
*/ */
int save(int confirm) int save(int confirm)
{ {
if(xctx->modified) struct stat buf;
char *name = xctx->sch[xctx->currsch];
int force = 0;
if(!stat(name, &buf)) {
if(xctx->time_last_modify && xctx->time_last_modify != buf.st_mtime) {
force = 1;
confirm = 0;
}
}
if(force || xctx->modified)
{ {
if(confirm) { if(confirm) {
tcleval("ask_save"); tcleval("ask_save");