MCPcopy Create free account
hub / github.com/eggert/tz / close_file

Function close_file

zic.c:826–846  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

824static void
825close_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
846ATTRIBUTE_NORETURN static void
847duplicate_options(char const *opt)
848{
849 fprintf(stderr, _("%s: More than one %s option specified\n"), progname, opt);

Callers 5

usageFunction · 0.70
mainFunction · 0.70
dolinkFunction · 0.70
infileFunction · 0.70
writezoneFunction · 0.70

Calls 1

chmetadataFunction · 0.85

Tested by

no test coverage detected