summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
authorgabrielstedman <gabriwinter@gmail.com>2019-04-22 08:58:26 (GMT)
committergabrielstedman <gabriwinter@gmail.com>2019-04-22 09:02:46 (GMT)
commit0acebbe53dd1b15071f2c48a7b060299b5d03622 (patch)
treeb5e09fc4253f29d6468358a4350c2b69fe4ac46a /programs
parent9d0960c354c9018957856334b1901bd693efe995 (diff)
downloadlz4-0acebbe53dd1b15071f2c48a7b060299b5d03622.zip
lz4-0acebbe53dd1b15071f2c48a7b060299b5d03622.tar.gz
lz4-0acebbe53dd1b15071f2c48a7b060299b5d03622.tar.bz2
FR #598 - Move LZ4F_compFileInfo_t def to lz4frame.h discard output_file
assert if in om_list mode
Diffstat (limited to 'programs')
-rw-r--r--programs/lz4cli.c13
-rw-r--r--programs/lz4io.c11
-rw-r--r--programs/lz4io.h8
3 files changed, 17 insertions, 15 deletions
diff --git a/programs/lz4cli.c b/programs/lz4cli.c
index 3315773..443e4b4 100644
--- a/programs/lz4cli.c
+++ b/programs/lz4cli.c
@@ -693,7 +693,7 @@ int main(int argc, const char** argv)
break;
}
- if (multiple_inputs==0) assert(output_filename);
+ if (multiple_inputs==0 && mode != om_list) assert(output_filename);
/* when multiple_inputs==1, output_filename may simply be useless,
* however, output_filename must be !NULL for next strcmp() tests */
if (!output_filename) output_filename = "*\\dummy^!//";
@@ -721,7 +721,14 @@ int main(int argc, const char** argv)
operationResult = LZ4IO_decompressMultipleFilenames(prefs, inFileNames, (int)ifnIdx, !strcmp(output_filename,stdoutmark) ? stdoutmark : LZ4_EXTENSION);
} else {
operationResult = DEFAULT_DECOMPRESSOR(prefs, input_filename, output_filename);
-
+ }
+ } else if (mode == om_list){
+ if(!multiple_inputs){
+ inFileNames[ifnIdx++] = input_filename;
+ }
+ operationResult = LZ4IO_displayCompressedFilesInfo(inFileNames, ifnIdx);
+ inFileNames=NULL;
+ } else { /* compression is default action */
if (legacy_format) {
DISPLAYLEVEL(3, "! Generating LZ4 Legacy format (deprecated) ! \n");
LZ4IO_compressFilename_Legacy(prefs, input_filename, output_filename, cLevel);
@@ -745,4 +752,4 @@ _cleanup:
LZ4IO_freePreferences(prefs);
free((void*)inFileNames);
return operationResult;
-}
+} \ No newline at end of file
diff --git a/programs/lz4io.c b/programs/lz4io.c
index 61fa13f..070e22a 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -1218,6 +1218,7 @@ static int LZ4IO_getCompressedFileInfo(const char* input_filename, LZ4F_compFil
const char *b,
*e;
char *t;
+ stat_t statbuf;
size_t readSize = LZ4F_HEADER_SIZE_MAX;
LZ4F_errorCode_t errorCode;
dRess_t ress;
@@ -1227,10 +1228,12 @@ static int LZ4IO_getCompressedFileInfo(const char* input_filename, LZ4F_compFil
if (finput==NULL) return 1;
/* Get file size */
- if (!UTIL_getFileStat(input_filename, &cfinfo->fileStat)){
+ if (!UTIL_getFileStat(input_filename, &statbuf)){
EXM_THROW(60, "Can't stat file : %s", input_filename);
}
+ cfinfo->fileSize = statbuf.st_size;
+
/* Get basename without extension */
b = strrchr(input_filename, '/');
if (!b){
@@ -1336,11 +1339,11 @@ int LZ4IO_displayCompressedFilesInfo(const char** inFileNames, const size_t ifnI
break;
}
if(cfinfo.frameInfo.contentSize){
- ratio = (double)cfinfo.fileStat.st_size / cfinfo.frameInfo.contentSize;
- DISPLAY("%-16d\t%-20lu\t%-20llu\t%-8.4f\t%s\n",cfinfo.frameInfo.blockChecksumFlag,cfinfo.fileStat.st_size,cfinfo.frameInfo.contentSize, ratio, cfinfo.fileName);
+ ratio = (double)cfinfo.fileSize / cfinfo.frameInfo.contentSize;
+ DISPLAY("%-16d\t%-20lu\t%-20llu\t%-8.4f\t%s\n",cfinfo.frameInfo.blockChecksumFlag,cfinfo.fileSize,cfinfo.frameInfo.contentSize, ratio, cfinfo.fileName);
}
else{
- DISPLAY("%-16d\t%-20lu\t%-20s\t%-10s\t%s\n",cfinfo.frameInfo.blockChecksumFlag,cfinfo.fileStat.st_size, "-", "-", cfinfo.fileName);
+ DISPLAY("%-16d\t%-20lu\t%-20s\t%-10s\t%s\n",cfinfo.frameInfo.blockChecksumFlag,cfinfo.fileSize, "-", "-", cfinfo.fileName);
}
}
return op_result;
diff --git a/programs/lz4io.h b/programs/lz4io.h
index fcda5f1..2008b55 100644
--- a/programs/lz4io.h
+++ b/programs/lz4io.h
@@ -52,14 +52,6 @@ static const char nulmark[] = "/dev/null";
/* ****************** Type Definitions ************** */
/* ************************************************** */
-typedef struct {
- LZ4F_frameInfo_t frameInfo;
- const char* fileName;
- stat_t fileStat;
-} LZ4F_compFileInfo_t;
-
-#define LZ4F_INIT_FILEINFO { (LZ4F_frameInfo_t) LZ4F_INIT_FRAMEINFO, NULL, stat_t() }
-
typedef struct LZ4IO_prefs_s LZ4IO_prefs_t;
LZ4IO_prefs_t* LZ4IO_defaultPreferences(void);