[vlc-commits] commit: vlc-cache-gen: add --force option ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sat Mar 6 18:16:57 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar  6 19:16:46 2010 +0200| [5a477c259b7d963ec8757348f01db81a1d39387d] | committer: Rémi Denis-Courmont 

vlc-cache-gen: add --force option

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5a477c259b7d963ec8757348f01db81a1d39387d
---

 bin/cachegen.c |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/bin/cachegen.c b/bin/cachegen.c
index 8c96f08..5223cfb 100644
--- a/bin/cachegen.c
+++ b/bin/cachegen.c
@@ -25,6 +25,7 @@
 #include <vlc/vlc.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 
 #ifdef HAVE_SETLOCALE
 # include <locale.h>
@@ -41,9 +42,11 @@ static void version (void)
 
 static void usage (const char *path)
 {
-    printf ("Usage: %s <path>\n"
-            "Generate the LibVLC plugins cache "
-            "for the specified plugins directory.\n", path);
+    printf (
+"Usage: %s [-f] <path>\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 */
@@ -54,6 +57,7 @@ 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'}
@@ -64,9 +68,14 @@ int main (int argc, char *argv[])
 #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;
@@ -87,14 +96,17 @@ int main (int argc, char *argv[])
         if (asprintf (&arg, "--plugin-path=%s", path) == -1)
             abort ();
 
-        const char *const vlc_argv[] = {
-            "--ignore-config",
-            "--quiet",
-            "--no-media-library",
-            arg,
-            NULL,
-        };
-        size_t vlc_argc = sizeof (vlc_argv) / sizeof (vlc_argv[0]) - 1;
+        const char *vlc_argv[7];
+        int vlc_argc = 0;
+
+        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 (vlc_argc, vlc_argv);
         if (vlc != NULL)



More information about the vlc-commits mailing list