mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-02-24 16:24:29 +01:00
Add initial argument processing for recursive option
This commit is contained in:
parent
32c7fa82a2
commit
8853f2e449
21
main.c
21
main.c
|
|
@ -65,7 +65,7 @@ static rzip_control base_control, local_control, *control;
|
|||
static void usage(bool compat)
|
||||
{
|
||||
print_output("lrz%s version %s\n", compat ? "" : "ip", PACKAGE_VERSION);
|
||||
print_output("Copyright (C) Con Kolivas 2006-2015\n");
|
||||
print_output("Copyright (C) Con Kolivas 2006-2016\n");
|
||||
print_output("Based on rzip ");
|
||||
print_output("Copyright (C) Andrew Tridgell 1998-2003\n\n");
|
||||
print_output("Usage: lrz%s [options] <file...>\n", compat ? "" : "ip");
|
||||
|
|
@ -85,6 +85,7 @@ static void usage(bool compat)
|
|||
print_output(" -P, --progress show compression progress\n");
|
||||
} else
|
||||
print_output(" -q, --quiet don't show compression progress\n");
|
||||
print_output(" -r, --recursive operate recursively on directories\n");
|
||||
print_output(" -t, --test test compressed file integrity\n");
|
||||
print_output(" -v[v%s], --verbose Increase verbosity\n", compat ? "v" : "");
|
||||
print_output(" -V, --version show version\n");
|
||||
|
|
@ -229,6 +230,7 @@ static struct option long_options[] = {
|
|||
{"threads", required_argument, 0, 'p'}, /* 20 */
|
||||
{"progress", no_argument, 0, 'P'},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{"recursive", no_argument, 0, 'r'},
|
||||
{"suffix", required_argument, 0, 'S'},
|
||||
{"test", no_argument, 0, 't'},
|
||||
{"threshold", required_argument, 0, 'T'}, /* 25 */
|
||||
|
|
@ -252,7 +254,7 @@ static void set_stdout(struct rzip_control *control)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool lrzcat = false, compat = false;
|
||||
bool lrzcat = false, compat = false, recurse = false;
|
||||
struct timeval start_time, end_time;
|
||||
struct sigaction handler;
|
||||
double seconds,total_time; // for timers
|
||||
|
|
@ -294,7 +296,7 @@ int main(int argc, char *argv[])
|
|||
else if (!strstr(eptr,"NOCONFIG"))
|
||||
read_config(control);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "bcCdDefghHikKlL:nN:o:O:pPqS:tTUm:vVw:z?123456789", long_options, &i)) != -1) {
|
||||
while ((c = getopt_long(argc, argv, "bcCdDefghHikKlL:nN:o:O:pPqrS:tTUm:vVw:z?123456789", long_options, &i)) != -1) {
|
||||
switch (c) {
|
||||
case 'b':
|
||||
if (control->flags & FLAG_NOT_LZMA)
|
||||
|
|
@ -400,6 +402,9 @@ int main(int argc, char *argv[])
|
|||
case 'q':
|
||||
control->flags &= ~FLAG_SHOW_PROGRESS;
|
||||
break;
|
||||
case 'r':
|
||||
recurse = true;
|
||||
break;
|
||||
case 'S':
|
||||
if (control->outname)
|
||||
failure("Specified output filename already, can't specify an extension.\n");
|
||||
|
|
@ -462,8 +467,12 @@ int main(int argc, char *argv[])
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (control->outname && argc > 1)
|
||||
failure("Cannot specify output filename with more than 1 file\n");
|
||||
if (control->outname) {
|
||||
if (argc > 1)
|
||||
failure("Cannot specify output filename with more than 1 file\n");
|
||||
if (recurse)
|
||||
failure("Cannot specify output filename with recursive\n");
|
||||
}
|
||||
|
||||
if (VERBOSE && !SHOW_PROGRESS) {
|
||||
print_err("Cannot have -v and -q options. -v wins.\n");
|
||||
|
|
@ -514,6 +523,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (recurse && (STDIN || STDOUT))
|
||||
failure("Cannot use -r recursive with STDIO\n");
|
||||
if (INFO && STDIN)
|
||||
failure("Will not get file info from STDIN\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,239 +0,0 @@
|
|||
#!/bin/bash
|
||||
#Very basic regression testing does a number of regular compression /
|
||||
#decompression / test cycles +/- STDIN +/- STDOUT and with the different
|
||||
#compression backends.
|
||||
#Run it with
|
||||
# regression_test.sh filename
|
||||
#where filename is any random file to test with (big or small depending on
|
||||
#what's being tested.
|
||||
|
||||
infile=$1
|
||||
|
||||
end(){
|
||||
rm -f lrztest lrztest.lrz
|
||||
}
|
||||
|
||||
if [ ! -e $infile ]; then
|
||||
echo $infile does not exist, exiting
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f lrztest ]; then
|
||||
echo lrztest file exists, exiting
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f lrztest.lrz ]; then
|
||||
echo lrztest.lrz file exists, exiting
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap 'echo "ABORTING";end;exit' 1 2 15
|
||||
|
||||
echo testing compression from stdin
|
||||
./lrzip -vvlfo lrztest.lrz < $infile
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing compression from stdin
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
rm lrztest.lrz
|
||||
|
||||
echo testing compression to stdout
|
||||
./lrzip -vvlo - $infile > lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing compression to stdout
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest.lrz
|
||||
echo testing compression from stdin to stdout
|
||||
./lrzip -vvl < $infile > lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing compression from stdin to stdout
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest.lrz
|
||||
echo testing standard compression
|
||||
./lrzip -vvlfo lrztest.lrz $infile
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing standard compression
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo testing standard decompression
|
||||
./lrzip -vvdo lrztest lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest ];then
|
||||
echo FAILED testing standard decompression
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest
|
||||
echo testing standard decompression with file checking
|
||||
./lrzip -vvdfco lrztest lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest ];then
|
||||
echo FAILED testing standard decompression with file checking
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest
|
||||
echo testing decompression from stdin
|
||||
./lrzip -vvfo lrztest -d < lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest ];then
|
||||
echo FAILED testing decompression from stdin
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest
|
||||
echo testing decompression to stdout
|
||||
./lrzip -vvdo - lrztest.lrz > lrztest
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest ];then
|
||||
echo FAILED testing decompression to stdout
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest
|
||||
echo testing decompression from stdin to stdout
|
||||
./lrzip -vvd < lrztest.lrz > lrztest
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest ];then
|
||||
echo FAILED testing decompression from stdin to stdout
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest
|
||||
echo testing testing
|
||||
./lrzip -vvt lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing testing
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo testing testing from stdin
|
||||
./lrzip -vvt < lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing testing from stdin
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest.lrz
|
||||
echo testing rzip only compression
|
||||
./lrzip -vvnfo lrztest.lrz $infile
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing rzip only compression
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo testing rzip only testing
|
||||
./lrzip -vvt lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing rzip only testing
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest.lrz
|
||||
echo testing lzma compression
|
||||
./lrzip -vvfo lrztest.lrz $infile
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing lzma compression
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo testing lzma testing
|
||||
./lrzip -vvt lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing lzma testing
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest.lrz
|
||||
echo testing gzip compression
|
||||
./lrzip -vvgfo lrztest.lrz $infile
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing gzip compression
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo testing gzip testing
|
||||
./lrzip -vvt lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing gzip testing
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest.lrz
|
||||
echo testing bzip2 compression
|
||||
./lrzip -vvbfo lrztest.lrz $infile
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing bzip2 compression
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo testing bzip2 testing
|
||||
./lrzip -vvt lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing bzip2 testing
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm lrztest.lrz
|
||||
echo testing zpaq compression
|
||||
./lrzip -vvzfo lrztest.lrz $infile
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing zpaq compression
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo testing zpaq testing
|
||||
./lrzip -vvt lrztest.lrz
|
||||
|
||||
if [ $? -ne 0 ] || [ ! -f lrztest.lrz ];then
|
||||
echo FAILED testing zpaq testing
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
||||
end
|
||||
|
||||
echo ALL TESTS SUCCESSFUL
|
||||
|
||||
exit 0
|
||||
Loading…
Reference in a new issue