From a685d5cffc26c9624c65521d26cba950e59c4cb3 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 22 Apr 2019 15:14:53 -0700 Subject: --list gives block type --- programs/lz4.1 | 2 +- programs/lz4.1.md | 5 ++--- programs/lz4io.c | 26 +++++++++++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/programs/lz4.1 b/programs/lz4.1 index eb82b68..ad0c12c 100644 --- a/programs/lz4.1 +++ b/programs/lz4.1 @@ -107,7 +107,7 @@ Benchmark mode, using \fB#\fR compression level\. . .TP \fB\-\-list\fR -List mode\. Lists information about \.lz4 files\. Useful if compressed with \-\-content\-size flag\. +List information about \.lz4 files\. note : current implementation is limited to single\-frame \.lz4 files\. . .SS "Operation modifiers" . diff --git a/programs/lz4.1.md b/programs/lz4.1.md index 62f672e..8874467 100644 --- a/programs/lz4.1.md +++ b/programs/lz4.1.md @@ -114,9 +114,8 @@ only the latest one will be applied. Benchmark mode, using `#` compression level. * `--list`: - List mode. - Lists information about .lz4 files. - Useful if compressed with --content-size flag. + List information about .lz4 files. + note : current implementation is limited to single-frame .lz4 files. ### Operation modifiers diff --git a/programs/lz4io.c b/programs/lz4io.c index 2a7b4b9..5393cd0 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -1304,7 +1304,6 @@ typedef enum { LZ4IO_LZ4F_OK, LZ4IO_format_not_known, LZ4IO_not_a_file } LZ4IO_i * + combine results from multiple frames, give total * - Optional : * + report nb of blocks, hence max. possible decompressed size (when not reported in header) - * + report block type (B4D, B7I, etc.) */ static LZ4IO_infoResult LZ4IO_getCompressedFileInfo(LZ4IO_cFileInfo_t* cfinfo, const char* input_filename) @@ -1355,13 +1354,26 @@ LZ4IO_getCompressedFileInfo(LZ4IO_cFileInfo_t* cfinfo, const char* input_filenam return result; } + +/* buffer : must be a valid memory area of at least 4 bytes */ +const char* LZ4IO_blockTypeID(int sizeID, int blockMode, char* buffer) +{ + buffer[0] = 'B'; + assert(sizeID >= 4); assert(sizeID <=7); + buffer[1] = (char)(sizeID + '0'); + buffer[2] = (blockMode == LZ4F_blockIndependent) ? 'I' : 'D'; + buffer[3] = 0; + return buffer; +} + + int LZ4IO_displayCompressedFilesInfo(const char** inFileNames, size_t ifnIdx) { int result = 0; size_t idx; - DISPLAY("%20s %20s %10s %7s %s\n", - "Compressed", "Uncompressed", "Ratio", "Check", "Filename"); + DISPLAY("%5s %20s %20s %10s %7s %s\n", + "Block", "Compressed", "Uncompressed", "Ratio", "Check", "Filename"); for (idx=0; idx