Changeset 1575:8fe87fc0ebc7
- Timestamp:
- 2000-02-29 14:30:09 (9 years ago)
- Author:
- Thomas Roessler <roessler@…>
- Branch:
- HEAD
- Message:
-
Add error checking to the recode-attachment code. From "Andrew W.
Nosenko" <awn@…>.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1433
|
r1575
|
|
| 1056 | 1056 | int c; |
| 1057 | 1057 | int rv = -1; |
| | 1058 | int source_file_is_unchanged = 1; |
| 1058 | 1059 | |
| 1059 | 1060 | size_t lf, lpu, lpo; |
| … |
… |
|
| 1094 | 1095 | mutt_decoder_pop (dec, tmp, sizeof (tmp), &lpo); |
| 1095 | 1096 | if (lpo) |
| 1096 | | fwrite (tmp, lpo, 1, tmpfp); |
| | 1097 | { |
| | 1098 | if (fwrite (tmp, lpo, 1, tmpfp) == EOF) |
| | 1099 | goto bail; |
| | 1100 | } |
| 1097 | 1101 | } |
| 1098 | 1102 | while (lpo); |
| 1099 | 1103 | } |
| 1100 | 1104 | } |
| | 1105 | if (lf == EOF && !feof(fp)) |
| | 1106 | { |
| | 1107 | goto bail; |
| | 1108 | } |
| 1101 | 1109 | |
| 1102 | 1110 | mutt_decoder_push (dec, NULL, 0, NULL); |
| … |
… |
|
| 1104 | 1112 | { |
| 1105 | 1113 | mutt_decoder_pop (dec, tmp, sizeof (tmp), &lpo); |
| 1106 | | if (lpo) fwrite (tmp, lpo, 1, tmpfp); |
| | 1114 | if (lpo) |
| | 1115 | { |
| | 1116 | if (fwrite (tmp, lpo, 1, tmpfp) == EOF) |
| | 1117 | goto bail; |
| | 1118 | } |
| 1107 | 1119 | } |
| 1108 | 1120 | while (lpo); |
| … |
… |
|
| 1112 | 1124 | fclose (fp); fp = NULL; |
| 1113 | 1125 | rewind (tmpfp); |
| | 1126 | |
| | 1127 | |
| | 1128 | source_file_is_unchanged = 0; |
| 1114 | 1129 | |
| 1115 | 1130 | /* don't use safe_fopen here - we're just going |
| 1116 | 1131 | * to overwrite the old file. |
| 1117 | 1132 | */ |
| 1118 | | |
| 1119 | 1133 | if ((fp = fopen (fname, "w")) == NULL) |
| 1120 | 1134 | goto bail; |
| … |
… |
|
| 1129 | 1143 | bail: |
| 1130 | 1144 | if (rv == -1) |
| 1131 | | mutt_error (_("Error while recoding %s. See %s for recovering your data."), |
| 1132 | | fname, tempfile); |
| | 1145 | { |
| | 1146 | if (source_file_is_unchanged) |
| | 1147 | { |
| | 1148 | mutt_error (_("Error while recoding %s. " |
| | 1149 | "Leave it unchanged."), |
| | 1150 | fname); |
| | 1151 | } |
| | 1152 | else |
| | 1153 | { |
| | 1154 | mutt_error (_("Error while recoding %s. " |
| | 1155 | "See %s for recovering your data."), |
| | 1156 | fname, tempfile); |
| | 1157 | } |
| | 1158 | } |
| 1133 | 1159 | |
| 1134 | 1160 | if (fp) fclose (fp); |