From 5fbef6a07470912e033f316eeb42ff3e54877f9d Mon Sep 17 00:00:00 2001 From: Andres Mejia Date: Sat, 22 Sep 2012 18:04:51 -0400 Subject: [PATCH] Implement command to test if commands are available in the current platform. --- libarchive/test/main.c | 12 ++++++++++++ libarchive/test/test.h | 3 +++ 2 files changed, 15 insertions(+) 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); -- 2.47.2