Commit 24b10179 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

files: beep whenever writing out a file fails

Just like when reading a file fails.  It needs the user's attention.
parent c14b581e
No related merge requests found
Showing with 11 additions and 11 deletions
+11 -11
......@@ -1965,7 +1965,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
tempname = safe_tempfile(&f);
if (tempname == NULL) {
statusline(HUSH, _("Error writing temp file: %s"),
statusline(ALERT, _("Error writing temp file: %s"),
strerror(errno));
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) {
statusline(HUSH, _("Error writing %s: %s"), tempname,
statusline(ALERT, _("Error writing temp file: %s"),
strerror(errno));
unlink(tempname);
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 (fd == -1) {
statusline(HUSH, _("Error writing %s: %s"), realname,
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
if (tempname != NULL)
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");
if (f == NULL) {
statusline(HUSH, _("Error writing %s: %s"), realname,
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
close(fd);
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);
if (size < data_len) {
statusline(HUSH, _("Error writing %s: %s"), realname,
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
fclose(f);
goto cleanup_and_exit;
......@@ -2057,7 +2057,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
#ifndef NANO_TINY
if (openfile->fmt == DOS_FILE || openfile->fmt == MAC_FILE) {
if (putc('\r', f) == EOF) {
statusline(HUSH, _("Error writing %s: %s"), realname,
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
fclose(f);
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)
#endif
if (putc('\n', f) == EOF) {
statusline(HUSH, _("Error writing %s: %s"), realname,
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
fclose(f);
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) {
statusline(HUSH, _("Error writing %s: %s"), realname,
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
unlink(tempname);
} else if (fclose(f) != 0) {
statusline(HUSH, _("Error writing %s: %s"), realname,
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
......
......@@ -3107,7 +3107,7 @@ void do_spell(void)
temp = safe_tempfile(&temp_file);
if (temp == NULL) {
statusline(HUSH, _("Error writing temp file: %s"), strerror(errno));
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
return;
}
......@@ -3119,7 +3119,7 @@ void do_spell(void)
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
if (!status) {
statusline(HUSH, _("Error writing temp file: %s"), strerror(errno));
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
free(temp);
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment