X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bin%2Fcachegen.c;h=5223cfb830c2c676f49a5ea3a3dd92ff2e9ecd42;hb=61f8e439fdaf29c2489ef4511f4fa2d17a38d1e6;hp=5792ea19658154ed0369b90f237cb3bd0c6f51ca;hpb=f974baf1756aebf491bfc51858de432540ea0959;p=vlc diff --git a/bin/cachegen.c b/bin/cachegen.c index 5792ea1965..5223cfb830 100644 --- a/bin/cachegen.c +++ b/bin/cachegen.c @@ -25,7 +25,11 @@ #include #include #include -#include +#include + +#ifdef HAVE_SETLOCALE +# include +#endif #ifdef HAVE_GETOPT_H # include @@ -38,9 +42,11 @@ static void version (void) static void usage (const char *path) { - printf ("Usage: %s \n" - "Generate the LibVLC plugins cache " - "for the specified plugins directory.\n", path); + printf ( +"Usage: %s [-f] \n" +"Generate the LibVLC plugins cache for the specified plugins directory.\n" +" -f, --force forcefully reset the plugin cache (if it exists)\n", + path); } /* Explicit HACK */ @@ -51,17 +57,25 @@ int main (int argc, char *argv[]) { static const struct option opts[] = { + { "force", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { NULL, no_argument, NULL, '\0'} }; +#ifdef HAVE_SETLOCALE setlocale (LC_CTYPE, ""); /* needed by FromLocale() */ +#endif int c; - while ((c = getopt_long (argc, argv, "hV", opts, NULL)) != -1) + bool force = false; + + while ((c = getopt_long (argc, argv, "fhV", opts, NULL)) != -1) switch (c) { + case 'f': + force = true; + break; case 'h': usage (argv[0]); return 0; @@ -82,17 +96,19 @@ int main (int argc, char *argv[]) if (asprintf (&arg, "--plugin-path=%s", path) == -1) abort (); - const char *const vlc_argv[] = { - "--ignore-config", - "--quiet", - arg, - NULL, - }; + const char *vlc_argv[7]; + int vlc_argc = 0; - libvlc_exception_t ex; - libvlc_exception_init (&ex); + vlc_argv[vlc_argc++] = "--ignore-config"; + vlc_argv[vlc_argc++] = "--quiet"; + vlc_argv[vlc_argc++] = "--no-media-library"; + if (force) + vlc_argv[vlc_argc++] = "--reset-plugins-cache"; + vlc_argv[vlc_argc++] = arg; + vlc_argv[vlc_argc++] = "--"; /* end of options */ + vlc_argv[vlc_argc] = NULL; - libvlc_instance_t *vlc = libvlc_new (3, vlc_argv, &ex); + libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv); if (vlc != NULL) libvlc_release (vlc); free (arg);