[PATCH 10/33] cfdisk: check writing to a file was successful

Sami Kerola
2013-04-13T19:55:34Z

fdisks/cfdisk.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/fdisks/cfdisk.c b/fdisks/cfdisk.c
index db9e233..dcaa05d 100644
--- a/fdisks/cfdisk.c
+++ b/fdisks/cfdisk.c
@@ -1849,7 +1849,11 @@ print_raw_table(void) {

if (to_file) {
if (!print_only)
- fclose(fp);
+ if (close_stream(fp) != 0) {
+ char errstr[LINE_LENGTH];
+ snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+ print_warning(errstr);
+ }
} else {
menuContinue();
}
@@ -1966,7 +1970,11 @@ print_p_info(void) {

if (to_file) {
if (!print_only)
- fclose(fp);
+ if (close_stream(fp) != 0) {
+ char errstr[LINE_LENGTH];
+ snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+ print_warning(errstr);
+ }
} else {
menuContinue();
}
@@ -2060,7 +2068,11 @@ print_part_table(void) {

if (to_file) {
if (!print_only)
- fclose(fp);
+ if (close_stream(fp) != 0) {
+ char errstr[LINE_LENGTH];
+ snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+ print_warning(errstr);
+ }
} else {
menuContinue();
}
--
1.8.2.1