summaryrefslogtreecommitdiffstats
path: root/ztest.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-08 04:37:53 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-08 04:37:53 +0000
commit77a9a9d380625670cd181c996aeb81343111a29d (patch)
tree566501beb43d4e2ed83350d70dfe8b9e5e886cb9 /ztest.cc
parentAdding upstream version 1.3~pre1. (diff)
downloadzutils-77a9a9d380625670cd181c996aeb81343111a29d.tar.xz
zutils-77a9a9d380625670cd181c996aeb81343111a29d.zip
Adding upstream version 1.3~pre2.upstream/1.3_pre2
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--ztest.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/ztest.cc b/ztest.cc
index 86a8518..cb78eb1 100644
--- a/ztest.cc
+++ b/ztest.cc
@@ -152,13 +152,24 @@ int ztest_file( const int infd, int format_index,
const std::string & input_filename,
const std::vector< const char * > & ztest_args )
{
+ static int disable_xz = -1; // tri-state bool
const uint8_t * magic_data = 0;
int magic_size = 0;
if( format_index < 0 )
format_index = test_format( infd, &magic_data, &magic_size );
const char * const compressor_name = get_compressor_name( format_index );
if( !compressor_name )
- return 0; // skip this file
+ return 0; // ignore this file
+ if( format_index == fmt_xz )
+ {
+ if( disable_xz < 0 )
+ {
+ std::string command( compressor_name ); command += " -V > /dev/null";
+ disable_xz = ( std::system( command.c_str() ) != 0 );
+ }
+ if( disable_xz ) return 0; // ignore this file if no xz installed
+ }
+
const pid_t pid = fork();
if( pid == 0 ) // child (compressor)