OSDN Git Service

tools: Stop converting file if write failed in seq2bseq
authorSzymon Janc <szymon.janc@tieto.com>
Mon, 13 Jan 2014 08:09:14 +0000 (09:09 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 13 Jan 2014 08:48:11 +0000 (10:48 +0200)
If write failed converted file would be broken. This make sure that
user is being informed about it.

tools/seq2bseq.c

index 9797f5f..7657a57 100644 (file)
@@ -130,6 +130,7 @@ static void convert_file(const char *input_path, const char *output_path)
 
        while (1) {
                char *str;
+               int err;
 
                str = fgets(line_buffer, line_size - 1, fp);
                if (!str)
@@ -137,7 +138,12 @@ static void convert_file(const char *input_path, const char *output_path)
 
                cur += strlen(str);
 
-               convert_line(fd, str);
+               err = convert_line(fd, str);
+               if (err < 0) {
+                       fprintf(stderr, "Failed to convert file (%s)\n",
+                                                               strerror(-err));
+                       break;
+               }
        }
 
        fclose(fp);