Skip to content

Commit

Permalink
Added ZSTDC_NO_DECOMPRESSOR macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Tokarev committed Dec 2, 2015
1 parent a174fb1 commit 777033b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion programs/fileio.c
Expand Up @@ -319,6 +319,7 @@ unsigned long long FIO_compressFilename(const char* output_filename, const char*
}


#ifndef ZSTDC_NO_DECOMPRESSOR
unsigned long long FIO_decompressFrame(FILE* foutput, FILE* finput,
BYTE* inBuff, size_t inBuffSize, size_t alreadyLoaded,
BYTE* outBuff, size_t outBuffSize,
Expand Down Expand Up @@ -411,5 +412,5 @@ unsigned long long FIO_decompressFilename(const char* output_filename, const cha

return filesize;
}

#endif

2 changes: 2 additions & 0 deletions programs/fileio.h
Expand Up @@ -53,7 +53,9 @@ void FIO_setNotificationLevel(unsigned level);
* Stream/File functions
***************************************/
unsigned long long FIO_compressFilename (const char* outfilename, const char* infilename, int compressionLevel);
#ifndef ZSTDC_NO_DECOMPRESSOR
unsigned long long FIO_decompressFilename (const char* outfilename, const char* infilename);
#endif
/**
FIO_compressFilename :
@result : size of compressed file
Expand Down
10 changes: 10 additions & 0 deletions programs/zstdcli.c
Expand Up @@ -120,7 +120,9 @@ static int usage(const char* programName)
DISPLAY( "Arguments :\n");
DISPLAY( " -1 : Fast compression (default) \n");
DISPLAY( " -9 : High compression \n");
#ifndef ZSTDC_NO_DECOMPRESSOR
DISPLAY( " -d : decompression (default for %s extension)\n", ZSTD_EXTENSION);
#endif
//DISPLAY( " -z : force compression\n");
DISPLAY( " -f : overwrite output without prompting \n");
DISPLAY( " -h/-H : display help/long help and exit\n");
Expand Down Expand Up @@ -178,7 +180,9 @@ int main(int argCount, const char** argv)
const char* inFileName = NULL;
const char* outFileName = NULL;
char* dynNameSpace = NULL;
#ifndef ZSTDC_NO_DECOMPRESSOR
const char extension[] = ZSTD_EXTENSION;
#endif

displayOut = stderr;
/* Pick out basename component. Don't rely on stdlib because of conflicting behavior. */
Expand Down Expand Up @@ -239,8 +243,10 @@ int main(int argCount, const char** argv)
/* Compression (default) */
//case 'z': forceCompress = 1; break;

#ifndef ZSTDC_NO_DECOMPRESSOR
/* Decoding */
case 'd': decode=1; argument++; break;
#endif

/* Force stdout, even if stdout==console */
case 'c': forceStdout=1; outFileName=stdoutmark; displayLevel=1; argument++; break;
Expand Down Expand Up @@ -345,6 +351,7 @@ int main(int argCount, const char** argv)
}
/* decompression to file (automatic name will work only if input filename has correct format extension) */
{
#ifndef ZSTDC_NO_DECOMPRESSOR
size_t filenameSize = strlen(inFileName);
if (strcmp(inFileName + (filenameSize-4), extension))
{
Expand All @@ -357,6 +364,7 @@ int main(int argCount, const char** argv)
strcpy(dynNameSpace, inFileName);
dynNameSpace[filenameSize-4]=0;
DISPLAYLEVEL(2, "Decoding file %s \n", outFileName);
#endif
}
}

Expand All @@ -368,9 +376,11 @@ int main(int argCount, const char** argv)

/* IO Stream/File */
FIO_setNotificationLevel(displayLevel);
#ifndef ZSTDC_NO_DECOMPRESSOR
if (decode)
FIO_decompressFilename(outFileName, inFileName);
else
#endif
FIO_compressFilename(outFileName, inFileName, cLevel);

_end:
Expand Down

0 comments on commit 777033b

Please sign in to comment.