diff options
author | Kyle J Harper <KyleJHarper@gmail.com> | 2015-04-12 22:28:13 (GMT) |
---|---|---|
committer | Kyle J Harper <KyleJHarper@gmail.com> | 2015-04-12 22:33:40 (GMT) |
commit | 0169502b49dfa5eb8878f5c85be3270012266fc3 (patch) | |
tree | 1145efbd28cb78f319e296582f2f9eb8c580f210 /programs/lz4io.c | |
parent | 160661c7a4cbf805f4af74d2e3932a17a66e6ce7 (diff) | |
download | lz4-0169502b49dfa5eb8878f5c85be3270012266fc3.zip lz4-0169502b49dfa5eb8878f5c85be3270012266fc3.tar.gz lz4-0169502b49dfa5eb8878f5c85be3270012266fc3.tar.bz2 |
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.
Diffstat (limited to 'programs/lz4io.c')
-rw-r--r-- | programs/lz4io.c | 28 |
1 files changed, 28 insertions, 0 deletions
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<ifntSize; i++) + { + size_t ifnSize = strlen(inFileNamesTable[i]); + strcpy(ifnSuffix, inFileNamesTable[i] + ifnSize - suffixSize); + DISPLAYLEVEL(2, "ifnSuffix is %s\n", ifnSuffix); + if (ofnSize <= ifnSize-suffixSize+1) { free(outFileName); ofnSize = ifnSize + 20; outFileName = (char*)malloc(ofnSize); } + if (ifnSize <= suffixSize || strcmp(ifnSuffix, suffix) != 0) { + DISPLAYLEVEL(2, "File extension doesn't match expected LZ4_EXTENSION (%4s); will not process file: %s\n", suffix, inFileNamesTable[i]); + skipped_files = 1; + continue; + } + memcpy(outFileName, inFileNamesTable[i], ifnSize - suffixSize); + outFileName[ifnSize-suffixSize] = '\0'; + LZ4IO_decompressFilename(inFileNamesTable[i], outFileName); + } + free(outFileName); + if (skipped_files) return 1; + return 0; +} /* ********************************************************************* */ /* ********************** LZ4 file-stream Decompression **************** */ |