? abort.patch ? shared-mime-info-spec.html Index: update-mime-database.c =================================================================== RCS file: /cvs/mime/shared-mime-info/update-mime-database.c,v retrieving revision 1.39 diff -u -p -r1.39 update-mime-database.c --- update-mime-database.c 19 Dec 2005 16:37:47 -0000 1.39 +++ update-mime-database.c 9 Jan 2007 15:28:13 -0000 @@ -2646,6 +2646,20 @@ write_cache (FILE *cache) } +static FILE * +open_or_die(const char *filename) +{ + FILE *stream = fopen(filename, "wb"); + + if (!stream) + { + g_printerr("Failed to open '%s' for writing\n", filename); + exit(EXIT_FAILURE); + } + + return stream; +} + int main(int argc, char **argv) { char *mime_dir = NULL; @@ -2668,7 +2682,7 @@ int main(int argc, char **argv) VERSION "\n" COPYING); return EXIT_SUCCESS; default: - abort(); + return EXIT_FAILURE; } } @@ -2733,10 +2747,7 @@ int main(int argc, char **argv) FILE *globs; char *globs_path; globs_path = g_strconcat(mime_dir, "/globs.new", NULL); - globs = fopen(globs_path, "wb"); - if (!globs) - g_error("Failed to open '%s' for writing\n", - globs_path); + globs = open_or_die(globs_path); fprintf(globs, "# This file was automatically generated by the\n" "# update-mime-database command. DO NOT EDIT!\n"); @@ -2752,10 +2763,7 @@ int main(int argc, char **argv) char *magic_path; int i; magic_path = g_strconcat(mime_dir, "/magic.new", NULL); - stream = fopen(magic_path, "wb"); - if (!stream) - g_error("Failed to open '%s' for writing\n", - magic_path); + stream = open_or_die(magic_path); fwrite("MIME-Magic\0\n", 1, 12, stream); if (magic_array->len) @@ -2777,11 +2785,7 @@ int main(int argc, char **argv) char *ns_path; ns_path = g_strconcat(mime_dir, "/XMLnamespaces.new", NULL); - stream = fopen(ns_path, "wb"); - if (!stream) - g_error("Failed to open '%s' for writing\n", - ns_path); - + stream = open_or_die(ns_path); write_namespaces(stream); atomic_update(ns_path); @@ -2793,11 +2797,7 @@ int main(int argc, char **argv) char *path; path = g_strconcat(mime_dir, "/subclasses.new", NULL); - stream = fopen(path, "wb"); - if (!stream) - g_error("Failed to open '%s' for writing\n", - path); - + stream = open_or_die(path); write_subclasses(stream); atomic_update(path); @@ -2809,11 +2809,7 @@ int main(int argc, char **argv) char *path; path = g_strconcat(mime_dir, "/aliases.new", NULL); - stream = fopen(path, "wb"); - if (!stream) - g_error("Failed to open '%s' for writing\n", - path); - + stream = open_or_die(path); write_aliases(stream); atomic_update(path); @@ -2825,11 +2821,7 @@ int main(int argc, char **argv) char *path; path = g_strconcat(mime_dir, "/mime.cache.new", NULL); - stream = fopen(path, "wb"); - if (!stream) - g_error("Failed to open '%s' for writing\n", - path); - + stream = open_or_die(path); write_cache(stream); atomic_update(path);