Fixed : default sparse mode disabled on stdout, to support >>
redirection scenario reported by Takayuki Matsuoka (#110)
This commit is contained in:
parent
91c1b9a682
commit
acae59a739
@ -171,6 +171,18 @@ test-lz4-sparse: lz4 datagen
|
||||
echo "Hello World 1 !" | ./lz4 | ./lz4 -d -c
|
||||
echo "Hello World 2 !" | ./lz4 | ./lz4 -d | cat
|
||||
echo "Hello World 3 !" | ./lz4 --no-frame-crc | ./lz4 -d -c
|
||||
@echo "\n Compatibility with Append :"
|
||||
./datagen -P100 -g1M > tmp1M
|
||||
cat tmp1M > tmp2M
|
||||
cat tmp1M >> tmp2M
|
||||
./lz4 -B5 -v tmp1M tmpC
|
||||
./lz4 -d -v tmpC tmpR
|
||||
./lz4 -d -v tmpC >> tmpR
|
||||
ls -ls tmp*
|
||||
diff tmp2M tmpR
|
||||
@rm tmp*
|
||||
|
||||
|
||||
|
||||
test-lz4-contentSize: lz4 datagen
|
||||
@echo "\n ---- test original size support ----"
|
||||
|
@ -306,7 +306,7 @@ int main(int argc, char** argv)
|
||||
if (!strcmp(argument, "--no-frame-crc")) { LZ4IO_setStreamChecksumMode(0); continue; }
|
||||
if (!strcmp(argument, "--content-size")) { LZ4IO_setContentSize(1); continue; }
|
||||
if (!strcmp(argument, "--no-content-size")) { LZ4IO_setContentSize(0); continue; }
|
||||
if (!strcmp(argument, "--sparse")) { LZ4IO_setSparseFile(1); continue; }
|
||||
if (!strcmp(argument, "--sparse")) { LZ4IO_setSparseFile(2); continue; }
|
||||
if (!strcmp(argument, "--no-sparse")) { LZ4IO_setSparseFile(0); continue; }
|
||||
if (!strcmp(argument, "--verbose")) { displayLevel=4; continue; }
|
||||
if (!strcmp(argument, "--quiet")) { if (displayLevel) displayLevel--; continue; }
|
||||
|
@ -278,6 +278,11 @@ static int LZ4IO_getFiles(const char* input_filename, const char* output_filenam
|
||||
DISPLAYLEVEL(4,"Using stdout for output\n");
|
||||
*pfoutput = stdout;
|
||||
SET_BINARY_MODE(stdout);
|
||||
if (g_sparseFileSupport==1)
|
||||
{
|
||||
g_sparseFileSupport = 0;
|
||||
DISPLAYLEVEL(4, "Sparse File Support is automatically disabled on stdout ; try --sparse \n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -303,13 +308,6 @@ static int LZ4IO_getFiles(const char* input_filename, const char* output_filenam
|
||||
|
||||
if (*pfoutput==0) EXM_THROW(13, "Pb opening %s", output_filename);
|
||||
|
||||
if (g_sparseFileSupport)
|
||||
{
|
||||
long int ftr = ftell(*pfoutput);
|
||||
/* DISPLAY("%s->%s ==> %i \n", input_filename, output_filename, (int)ftr); */
|
||||
if (ftr!=0) g_sparseFileSupport = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -674,7 +672,7 @@ static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t buffer
|
||||
{
|
||||
size_t sizeCheck;
|
||||
seekResult = fseek(file, storedSkips, SEEK_CUR);
|
||||
if (seekResult) EXM_THROW(72, "Skip error (sparse file)");
|
||||
if (seekResult) EXM_THROW(72, "Sparse skip error ; try --no-sparse");
|
||||
storedSkips = 0;
|
||||
seg0SizeT -= nb0T;
|
||||
ptrT += nb0T;
|
||||
@ -696,7 +694,7 @@ static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t buffer
|
||||
{
|
||||
size_t sizeCheck;
|
||||
int seekResult = fseek(file, storedSkips, SEEK_CUR);
|
||||
if (seekResult) EXM_THROW(74, "Skip error (end of block)");
|
||||
if (seekResult) EXM_THROW(74, "Sparse skip error ; try --no-sparse");
|
||||
storedSkips = 0;
|
||||
sizeCheck = fwrite(restPtr, 1, restEnd - restPtr, file);
|
||||
if (sizeCheck != (size_t)(restEnd - restPtr)) EXM_THROW(75, "Write error : cannot write decoded end of block");
|
||||
|
Loading…
Reference in New Issue
Block a user