From 0169502b49dfa5eb8878f5c85be3270012266fc3 Mon Sep 17 00:00:00 2001 From: Kyle J Harper Date: Sun, 12 Apr 2015 17:28:13 -0500 Subject: Added new LZ4IO_decompressMultipleFilenames to allow decompression of multiple files with the -m switch added in r128 (ref: google code issue 151). Limitation: will only process files matching LZ4_EXTENSION macro, which for now seems reasonable. --- programs/lz4cli.c | 32 +++++++++++++++++++------------- programs/lz4io.c | 28 ++++++++++++++++++++++++++++ programs/lz4io.h | 3 ++- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/programs/lz4cli.c b/programs/lz4cli.c index da5da71..f7cf27e 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -515,22 +515,28 @@ int main(int argc, char** argv) /* IO Stream/File */ LZ4IO_setNotificationLevel(displayLevel); - if (decode) DEFAULT_DECOMPRESSOR(input_filename, output_filename); + if (decode) + { + if (multiple_inputs) + LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION); + else + DEFAULT_DECOMPRESSOR(input_filename, output_filename); + } else { - /* compression is default action */ - if (legacy_format) - { - DISPLAYLEVEL(3, "! Generating compressed LZ4 using Legacy format (deprecated) ! \n"); - LZ4IO_compressFilename_Legacy(input_filename, output_filename, cLevel); - } + /* compression is default action */ + if (legacy_format) + { + DISPLAYLEVEL(3, "! Generating compressed LZ4 using Legacy format (deprecated) ! \n"); + LZ4IO_compressFilename_Legacy(input_filename, output_filename, cLevel); + } + else + { + if (multiple_inputs) + LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel); else - { - if (multiple_inputs) - LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel); - else - DEFAULT_COMPRESSOR(input_filename, output_filename, cLevel); - } + DEFAULT_COMPRESSOR(input_filename, output_filename, cLevel); + } } if (main_pause) waitEnter(); diff --git a/programs/lz4io.c b/programs/lz4io.c index 02e03c8..16a588c 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -517,6 +517,34 @@ int LZ4IO_compressMultipleFilenames(const char** inFileNamesTable, int ifntSize, return 0; } +int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSize, const char* suffix) +{ + int i; + int skipped_files = 0; + char* outFileName = (char*)malloc(FNSPACE); + size_t ofnSize = FNSPACE; + size_t suffixSize = strlen(suffix); + char* ifnSuffix = (char*)malloc(suffixSize + 1); + + for (i=0; i Date: Sun, 12 Apr 2015 18:41:55 -0500 Subject: Added support for continuation of file compression and decompression if input files are missing. Should more closely match gzip/bzip2/xz and so forth. Also removed a debug print accidentally left in. --- programs/lz4cli.c | 8 +++++--- programs/lz4io.c | 25 ++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/programs/lz4cli.c b/programs/lz4cli.c index f7cf27e..f3524b3 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -265,7 +265,8 @@ int main(int argc, char** argv) forceStdout=0, forceCompress=0, main_pause=0, - multiple_inputs=0; + multiple_inputs=0, + multiple_rv=0; const char* input_filename=0; const char* output_filename=0; char* dynNameSpace=0; @@ -518,7 +519,7 @@ int main(int argc, char** argv) if (decode) { if (multiple_inputs) - LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION); + multiple_rv = LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION); else DEFAULT_DECOMPRESSOR(input_filename, output_filename); } @@ -533,7 +534,7 @@ int main(int argc, char** argv) else { if (multiple_inputs) - LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel); + multiple_rv = LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel); else DEFAULT_COMPRESSOR(input_filename, output_filename, cLevel); } @@ -542,5 +543,6 @@ int main(int argc, char** argv) if (main_pause) waitEnter(); free(dynNameSpace); free((void*)inFileNames); + if (multiple_rv != 0) return multiple_rv; return 0; } diff --git a/programs/lz4io.c b/programs/lz4io.c index 16a588c..d399c90 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -501,12 +501,21 @@ int LZ4IO_compressFilename(const char* input_filename, const char* output_filena int LZ4IO_compressMultipleFilenames(const char** inFileNamesTable, int ifntSize, const char* suffix, int compressionlevel) { int i; + int missing_files = 0; + FILE *ifp; char* outFileName = (char*)malloc(FNSPACE); size_t ofnSize = FNSPACE; const size_t suffixSize = strlen(suffix); for (i=0; i 0) return 1; return 0; } @@ -521,6 +531,8 @@ int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSiz { int i; int skipped_files = 0; + int missing_files = 0; + FILE *ifp; char* outFileName = (char*)malloc(FNSPACE); size_t ofnSize = FNSPACE; size_t suffixSize = strlen(suffix); @@ -528,13 +540,19 @@ int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSiz for (i=0; i 0) return 1; + if (missing_files > 0) return 1; return 0; } -- cgit v0.12