Close STREAM. If it had an I/O error, report it against DIR/NAME, remove TEMPNAME if nonnull, and then exit. If TEMPNAME is nonnull, and if requested, change the stream's metadata before closing. */
| 824 | static void |
| 825 | close_file(FILE *stream, char const *dir, char const *name, |
| 826 | char const *tempname) |
| 827 | { |
| 828 | char const *e = (ferror(stream) ? _("I/O error") |
| 829 | : ((tempname |
| 830 | && (fflush(stream) < 0 || chmetadata(stream) < 0)) |
| 831 | || fclose(stream) < 0) |
| 832 | ? strerror(errno) : NULL); |
| 833 | if (e) { |
| 834 | if (name && *name == '/') |
| 835 | dir = NULL; |
| 836 | fprintf(stderr, "%s: %s%s%s%s%s\n", progname, |
| 837 | dir ? dir : "", dir ? "/" : "", |
| 838 | name ? name : "", name ? ": " : "", |
| 839 | e); |
| 840 | if (tempname) |
| 841 | remove_temp(tempname); |
| 842 | exit(EXIT_FAILURE); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | ATTRIBUTE_NORETURN static void |
| 847 | duplicate_options(char const *opt) |
| 848 | { |
| 849 | fprintf(stderr, _("%s: More than one %s option specified\n"), progname, opt); |