summaryrefslogtreecommitdiffstats
path: root/programs/lz4io.c
diff options
context:
space:
mode:
authorNick Terrell <terrelln@fb.com>2016-11-03 22:41:09 (GMT)
committerNick Terrell <terrelln@fb.com>2016-11-03 22:41:09 (GMT)
commit3dcafd35d409380182393fdb0d5666f6a64ff841 (patch)
tree9990be07a0bd61e2202387c7509850c6979a4aa5 /programs/lz4io.c
parent6f68a1692e58b0380e5f88d8be61656ead8331f4 (diff)
downloadlz4-3dcafd35d409380182393fdb0d5666f6a64ff841.zip
lz4-3dcafd35d409380182393fdb0d5666f6a64ff841.tar.gz
lz4-3dcafd35d409380182393fdb0d5666f6a64ff841.tar.bz2
Fix test mode and write to null
Fix test mode to not always return success. Don't ask for permission to overwrite `nulmark`. Before: > echo "hello world" > file > lz4 -t file successfully decoded 12 bytes > lz4 -tf file successfully decoded 12 bytes > lz4 file null Warning : /dev/null already exists Overwrite ? (Y/n) : n Error 12 : No. Operation aborted : /dev/null already exists > lz4 file /dev/null Warning : /dev/null already exists Overwrite ? (Y/n) : n Error 12 : No. Operation aborted : /dev/null already exists After: > lz4 -t file Error 44 : Unrecognized header : file cannot be decoded > lz4 -tf file Error 44 : Unrecognized header : file cannot be decoded > lz4 file null Compressed 12 bytes into 31 bytes ==> 258.33% > lz4 file /dev/null Compressed 12 bytes into 31 bytes ==> 258.33%
Diffstat (limited to 'programs/lz4io.c')
-rw-r--r--programs/lz4io.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index f2d7b51..3a85830 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -136,6 +136,7 @@ static clock_t g_time = 0;
* Local Parameters
**************************************/
static int g_overwrite = 1;
+static int g_passThrough = 1;
static int g_blockSizeId = LZ4IO_BLOCKSIZEID_DEFAULT;
static int g_blockChecksum = 0;
static int g_streamChecksum = 1;
@@ -184,6 +185,13 @@ int LZ4IO_setOverwrite(int yes)
return g_overwrite;
}
+/* Default setting : passThrough = 1; return : passThrough mode (0/1) */
+int LZ4IO_setPassThrough(int yes)
+{
+ g_passThrough = (yes!=0);
+ return g_passThrough;
+}
+
/* blockSizeID : valid values : 4-5-6-7 */
int LZ4IO_setBlockSizeID(int bsid)
{
@@ -283,7 +291,7 @@ static int LZ4IO_getFiles(const char* input_filename, const char* output_filenam
} else {
/* Check if destination file already exists */
*pfoutput=0;
- if (output_filename != nulmark) *pfoutput = fopen( output_filename, "rb" );
+ if (strcmp(output_filename, nulmark)) *pfoutput = fopen( output_filename, "rb" );
if (*pfoutput!=0) {
fclose(*pfoutput);
if (!g_overwrite) {
@@ -908,7 +916,7 @@ static unsigned long long selectDecoder(dRess_t ress, FILE* finput, FILE* foutpu
EXTENDED_FORMAT; /* macro extension for custom formats */
default:
if (nbCalls == 1) { /* just started */
- if (g_overwrite)
+ if (g_passThrough && g_overwrite)
return LZ4IO_passThrough(finput, foutput, MNstore);
EXM_THROW(44,"Unrecognized header : file cannot be decoded"); /* Wrong magic number at the beginning of 1st stream */
}