From: Andres Mejia Date: Sat, 22 Sep 2012 22:04:51 +0000 (-0400) Subject: Implement command to test if commands are available in the current platform. X-Git-Tag: v3.1.0~19^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fbef6a07470912e033f316eeb42ff3e54877f9d;p=thirdparty%2Flibarchive.git Implement command to test if commands are available in the current platform. --- diff --git a/libarchive/test/main.c b/libarchive/test/main.c index 68e965adc..5f9b4825d 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -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) { diff --git a/libarchive/test/test.h b/libarchive/test/test.h index 11f173711..7ca2da7ac 100644 --- a/libarchive/test/test.h +++ b/libarchive/test/test.h @@ -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);