]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Implement command to test if commands are available in the current platform.
authorAndres Mejia <amejia004@gmail.com>
Sat, 22 Sep 2012 22:04:51 +0000 (18:04 -0400)
committerAndres Mejia <amejia004@gmail.com>
Fri, 7 Dec 2012 23:22:11 +0000 (18:22 -0500)
libarchive/test/main.c
libarchive/test/test.h

index 68e965adcfc54fbf980244ac1bc86b950e420b89..5f9b4825dc3c2892e233693df110c4399d1a2c04 100644 (file)
@@ -1911,6 +1911,18 @@ canGzip(void)
 /*
  * Can this platform run the lrzip program?
  */
+int
+canRunCommand(const char *cmd)
+{
+  static int tested = 0, value = 0;
+  if (!tested) {
+    tested = 1;
+    if (systemf("%s %s", cmd, redirectArgs) == 0)
+      value = 1;
+  }
+  return (value);
+}
+
 int
 canLrzip(void)
 {
index 11f1737118ee6fc9ce1abd785f3ecacb76a2bc9e..7ca2da7ac39e66e90e7d72343119519f405e5b8a 100644 (file)
@@ -275,6 +275,9 @@ int canGrzip(void);
 /* Return true if this platform can run the "gzip" program. */
 int canGzip(void);
 
+/* Return true if this platform can run the specified command. */
+int canRunCommand(const char *);
+
 /* Return true if this platform can run the "lrzip" program. */
 int canLrzip(void);