diff options
author | Yann Collet <cyan@fb.com> | 2019-04-22 22:14:53 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2019-04-22 22:14:53 (GMT) |
commit | a685d5cffc26c9624c65521d26cba950e59c4cb3 (patch) | |
tree | 1e0e2b4b187bf96109fb179a2ab60482db2097b5 | |
parent | f401f1de7eba98ee5acde5b8dd9681ff1aa76b56 (diff) | |
download | lz4-a685d5cffc26c9624c65521d26cba950e59c4cb3.zip lz4-a685d5cffc26c9624c65521d26cba950e59c4cb3.tar.gz lz4-a685d5cffc26c9624c65521d26cba950e59c4cb3.tar.bz2 |
--list gives block type
-rw-r--r-- | programs/lz4.1 | 2 | ||||
-rw-r--r-- | programs/lz4.1.md | 5 | ||||
-rw-r--r-- | 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<ifnIdx; idx++) { /* Get file info */ @@ -1378,14 +1390,18 @@ int LZ4IO_displayCompressedFilesInfo(const char** inFileNames, size_t ifnIdx) continue; } if (cfinfo.frameInfo.contentSize) { + char buffer[5]; double const ratio = (double)cfinfo.fileSize / cfinfo.frameInfo.contentSize; - DISPLAY("%20llu %20llu %8.4f %7s %s \n", + DISPLAY("%5s %20llu %20llu %8.4f %7s %s \n", + LZ4IO_blockTypeID(cfinfo.frameInfo.blockSizeID, cfinfo.frameInfo.blockMode, buffer), cfinfo.fileSize, cfinfo.frameInfo.contentSize, ratio, cfinfo.frameInfo.contentChecksumFlag ? "XXH32" : "-", cfinfo.fileName); } else { - DISPLAY("%20llu %20s %10s %7s %s \n", + char buffer[5]; + DISPLAY("%5s %20llu %20s %10s %7s %s \n", + LZ4IO_blockTypeID(cfinfo.frameInfo.blockSizeID, cfinfo.frameInfo.blockMode, buffer), cfinfo.fileSize, "-", "-", cfinfo.frameInfo.contentChecksumFlag ? "XXH32" : "-", |