diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-07-14 12:18:35 -0400 |
---|---|---|
committer | Vincent Untz <vuntz@gnome.org> | 2013-08-29 09:51:23 +0200 |
commit | 0b6e84cd489091b5fdaea6ffac0fc8a83589e8c7 (patch) | |
tree | 7415805e0f20e8e79285c76223dd519e75f5d90d | |
parent | fd0df83df2531e3e25b4d56d0450b39004b8ed20 (diff) |
Allow validating multiple desktop files
There is no good reason to not allow this.
https://bugs.freedesktop.org/show_bug.cgi?id=60744
-rw-r--r-- | src/validator.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/validator.c b/src/validator.c index b04dd34..e15f9f3 100644 --- a/src/validator.c +++ b/src/validator.c @@ -37,7 +37,7 @@ static GOptionEntry option_entries[] = { { "no-hints", 0, 0, G_OPTION_ARG_NONE, &no_hints, "Do not output hints to improve desktop file", NULL }, { "no-warn-deprecated", 0, 0, G_OPTION_ARG_NONE, &no_warn_deprecated, "Do not warn about usage of deprecated items", NULL }, { "warn-kde", 0, 0, G_OPTION_ARG_NONE, &warn_kde, "Warn if KDE extensions to the specification are used", NULL }, - { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filename, NULL, "<desktop-file>" }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filename, NULL, "<desktop-file>..." }, { NULL } }; @@ -46,6 +46,8 @@ main (int argc, char *argv[]) { GOptionContext *context; GError *error; + int i; + gboolean all_valid; context = g_option_context_new (NULL); g_option_context_set_summary (context, "Validate desktop entry files " @@ -66,19 +68,24 @@ main (int argc, char *argv[]) g_option_context_free (context); - /* only accept one desktop file argument */ - if (filename == NULL || filename[0] == NULL || filename[1] != NULL) { + if (filename == NULL || filename[0] == NULL) { g_printerr ("See \"%s --help\" for correct usage.\n", g_get_prgname ()); return 1; } - if (!g_file_test (filename[0], G_FILE_TEST_IS_REGULAR)) { - g_printerr ("%s: file does not exist\n", filename[0]); - return 1; + all_valid = TRUE; + for (i = 0; filename[i]; i++) { + if (!g_file_test (filename[i], G_FILE_TEST_IS_REGULAR)) { + g_printerr ("%s: file does not exist\n", filename[i]); + all_valid = FALSE; + } + + if (!desktop_file_validate (filename[i], warn_kde, no_warn_deprecated, no_hints)) + all_valid = FALSE; } - if (desktop_file_validate (filename[0], warn_kde, no_warn_deprecated, no_hints)) - return 0; - else + if (!all_valid) return 1; + + return 0; } |