files: beep whenever writing out a file fails
Just like when reading a file fails. It needs the user's attention.master
parent
c14b581e0a
commit
24b10179a1
18
src/files.c
18
src/files.c
|
@ -1965,7 +1965,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
tempname = safe_tempfile(&f);
|
tempname = safe_tempfile(&f);
|
||||||
|
|
||||||
if (tempname == NULL) {
|
if (tempname == NULL) {
|
||||||
statusline(HUSH, _("Error writing temp file: %s"),
|
statusline(ALERT, _("Error writing temp file: %s"),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
}
|
}
|
||||||
|
@ -1987,7 +1987,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f_source == NULL || copy_file(f_source, f) != 0) {
|
if (f_source == NULL || copy_file(f_source, f) != 0) {
|
||||||
statusline(HUSH, _("Error writing %s: %s"), tempname,
|
statusline(ALERT, _("Error writing temp file: %s"),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
unlink(tempname);
|
unlink(tempname);
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
|
@ -2006,7 +2006,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
|
|
||||||
/* If we couldn't open the file, give up. */
|
/* If we couldn't open the file, give up. */
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
statusline(HUSH, _("Error writing %s: %s"), realname,
|
statusline(ALERT, _("Error writing %s: %s"), realname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
if (tempname != NULL)
|
if (tempname != NULL)
|
||||||
unlink(tempname);
|
unlink(tempname);
|
||||||
|
@ -2016,7 +2016,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
f = fdopen(fd, (append == APPEND) ? "ab" : "wb");
|
f = fdopen(fd, (append == APPEND) ? "ab" : "wb");
|
||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
statusline(HUSH, _("Error writing %s: %s"), realname,
|
statusline(ALERT, _("Error writing %s: %s"), realname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
|
@ -2040,7 +2040,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
unsunder(fileptr->data, data_len);
|
unsunder(fileptr->data, data_len);
|
||||||
|
|
||||||
if (size < data_len) {
|
if (size < data_len) {
|
||||||
statusline(HUSH, _("Error writing %s: %s"), realname,
|
statusline(ALERT, _("Error writing %s: %s"), realname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
|
@ -2057,7 +2057,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (openfile->fmt == DOS_FILE || openfile->fmt == MAC_FILE) {
|
if (openfile->fmt == DOS_FILE || openfile->fmt == MAC_FILE) {
|
||||||
if (putc('\r', f) == EOF) {
|
if (putc('\r', f) == EOF) {
|
||||||
statusline(HUSH, _("Error writing %s: %s"), realname,
|
statusline(ALERT, _("Error writing %s: %s"), realname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
|
@ -2067,7 +2067,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
if (openfile->fmt != MAC_FILE)
|
if (openfile->fmt != MAC_FILE)
|
||||||
#endif
|
#endif
|
||||||
if (putc('\n', f) == EOF) {
|
if (putc('\n', f) == EOF) {
|
||||||
statusline(HUSH, _("Error writing %s: %s"), realname,
|
statusline(ALERT, _("Error writing %s: %s"), realname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
|
@ -2099,14 +2099,14 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_file(f_source, f) == -1) {
|
if (copy_file(f_source, f) == -1) {
|
||||||
statusline(HUSH, _("Error writing %s: %s"), realname,
|
statusline(ALERT, _("Error writing %s: %s"), realname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink(tempname);
|
unlink(tempname);
|
||||||
} else if (fclose(f) != 0) {
|
} else if (fclose(f) != 0) {
|
||||||
statusline(HUSH, _("Error writing %s: %s"), realname,
|
statusline(ALERT, _("Error writing %s: %s"), realname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3107,7 +3107,7 @@ void do_spell(void)
|
||||||
temp = safe_tempfile(&temp_file);
|
temp = safe_tempfile(&temp_file);
|
||||||
|
|
||||||
if (temp == NULL) {
|
if (temp == NULL) {
|
||||||
statusline(HUSH, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3119,7 +3119,7 @@ void do_spell(void)
|
||||||
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
|
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
statusline(HUSH, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
free(temp);
|
free(temp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue