mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 21:01:24 +03:00
tweaks: slightly improve a comment and the ordering of some lines
This commit is contained in:
parent
69e6ccf641
commit
a2b7fc1c81
36
src/files.c
36
src/files.c
@ -1594,12 +1594,10 @@ int sync_file(FILE *thefile)
|
|||||||
* then in the user's home directory). Return TRUE if the save can proceed. */
|
* then in the user's home directory). Return TRUE if the save can proceed. */
|
||||||
bool backup_file(char *realname, char **backupname)
|
bool backup_file(char *realname, char **backupname)
|
||||||
{
|
{
|
||||||
bool second_attempt = FALSE;
|
|
||||||
/* Whether a normal backup failed and we are resorting to a failsafe. */
|
|
||||||
|
|
||||||
static struct timespec filetime[2];
|
|
||||||
int backup_cflags, backup_fd, verdict;
|
|
||||||
FILE *original = NULL, *backup_file = NULL;
|
FILE *original = NULL, *backup_file = NULL;
|
||||||
|
int backup_cflags, backup_fd, verdict;
|
||||||
|
static struct timespec filetime[2];
|
||||||
|
bool second_attempt = FALSE;
|
||||||
|
|
||||||
/* Remember the original file's access and modification times. */
|
/* Remember the original file's access and modification times. */
|
||||||
filetime[0].tv_sec = openfile->statinfo->st_atime;
|
filetime[0].tv_sec = openfile->statinfo->st_atime;
|
||||||
@ -1720,31 +1718,31 @@ bool backup_file(char *realname, char **backupname)
|
|||||||
unlink(*backupname);
|
unlink(*backupname);
|
||||||
free(*backupname);
|
free(*backupname);
|
||||||
|
|
||||||
*backupname = charalloc(strlen(homedir) + strlen(tail(realname)) + 9);
|
|
||||||
sprintf(*backupname, "%s/%s~XXXXXX", homedir, tail(realname));
|
|
||||||
|
|
||||||
backup_fd = mkstemp(*backupname);
|
|
||||||
backup_file = NULL;
|
|
||||||
|
|
||||||
if (ISSET(MAKE_BACKUP)) {
|
if (ISSET(MAKE_BACKUP)) {
|
||||||
warn_and_briefly_pause(_("Cannot make regular backup"));
|
warn_and_briefly_pause(_("Cannot make regular backup"));
|
||||||
warn_and_briefly_pause(_("Trying again in your home directory"));
|
warn_and_briefly_pause(_("Trying again in your home directory"));
|
||||||
currmenu = MMOST;
|
currmenu = MMOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*backupname = charalloc(strlen(homedir) + strlen(tail(realname)) + 9);
|
||||||
|
sprintf(*backupname, "%s/%s~XXXXXX", homedir, tail(realname));
|
||||||
|
|
||||||
|
backup_fd = mkstemp(*backupname);
|
||||||
|
backup_file = NULL;
|
||||||
|
|
||||||
second_attempt = TRUE;
|
second_attempt = TRUE;
|
||||||
goto retry_backup;
|
goto retry_backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If all attempts failed, notify the user, because if something goes
|
/* If all attempts failed, ask the user what to do, because if something
|
||||||
* wrong during the save, the contents of the file might be lost. */
|
* goes wrong during the save, the contents of the file might be lost. */
|
||||||
warn_and_briefly_pause(_("Cannot make backup"));
|
warn_and_briefly_pause(_("Cannot make backup"));
|
||||||
if (!user_wants_to_proceed()) {
|
if (user_wants_to_proceed())
|
||||||
statusline(HUSH, _("Cannot write backup %s: %s"),
|
return TRUE;
|
||||||
*backupname, strerror(errno));
|
|
||||||
return FALSE;
|
statusline(HUSH, _("Cannot write backup %s: %s"),
|
||||||
}
|
*backupname, strerror(errno));
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user