Merge pull request #1790 from stokito/tzst-ext
Add short tar's extensions .tgz (.tar.gz), .txz (.tar.xz), .tzst (.tar.zst)
This commit is contained in:
commit
30b27ee0c9
@ -5,9 +5,9 @@ use case sensitivity that matches modern (ie. cmake version 2.6 and above)
|
||||
conventions of using lower-case for commands, and upper-case for
|
||||
variables.
|
||||
|
||||
# How to build
|
||||
## How to build
|
||||
|
||||
As cmake doesn't support command like `cmake clean`, it's recommanded to perform a "out of source build".
|
||||
As cmake doesn't support command like `cmake clean`, it's recommended to perform a "out of source build".
|
||||
To do this, you can create a new directory and build in it:
|
||||
```sh
|
||||
cd build/cmake
|
||||
@ -16,7 +16,7 @@ cd builddir
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
Then you can clean all cmake caches by simpily delete the new directory:
|
||||
Then you can clean all cmake caches by simply delete the new directory:
|
||||
```sh
|
||||
rm -rf build/cmake/builddir
|
||||
```
|
||||
@ -34,19 +34,19 @@ cd build/cmake/builddir
|
||||
cmake -LH ..
|
||||
```
|
||||
|
||||
Bool options can be set to ON/OFF with -D\[option\]=\[ON/OFF\]. You can configure cmake options like this:
|
||||
Bool options can be set to `ON/OFF` with `-D[option]=[ON/OFF]`. You can configure cmake options like this:
|
||||
```sh
|
||||
cd build/cmake/builddir
|
||||
cmake -DZSTD_BUILD_TESTS=ON -DZSTD_LEGACY_SUPPORT=ON ..
|
||||
make
|
||||
```
|
||||
|
||||
## referring
|
||||
### referring
|
||||
[Looking for a 'cmake clean' command to clear up CMake output](https://stackoverflow.com/questions/9680420/looking-for-a-cmake-clean-command-to-clear-up-cmake-output)
|
||||
|
||||
# CMake Style Recommendations
|
||||
## CMake Style Recommendations
|
||||
|
||||
## Indent all code correctly, i.e. the body of
|
||||
### Indent all code correctly, i.e. the body of
|
||||
|
||||
* if/else/endif
|
||||
* foreach/endforeach
|
||||
@ -57,7 +57,7 @@ make
|
||||
Use spaces for indenting, 2, 3 or 4 spaces preferably. Use the same amount of
|
||||
spaces for indenting as is used in the rest of the file. Do not use tabs.
|
||||
|
||||
## Upper/lower casing
|
||||
### Upper/lower casing
|
||||
|
||||
Most important: use consistent upper- or lowercasing within one file !
|
||||
|
||||
@ -77,7 +77,7 @@ Add_Executable(hello hello.c)
|
||||
aDd_ExEcUtAbLe(blub blub.c)
|
||||
```
|
||||
|
||||
## End commands
|
||||
### End commands
|
||||
To make the code easier to read, use empty commands for endforeach(), endif(),
|
||||
endfunction(), endmacro() and endwhile(). Also, use empty else() commands.
|
||||
|
||||
@ -99,6 +99,6 @@ if(BARVAR)
|
||||
endif(BARVAR)
|
||||
```
|
||||
|
||||
## Other resources for best practices
|
||||
### Other resources for best practices
|
||||
|
||||
`https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#modules`
|
||||
https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#modules
|
||||
|
@ -2298,44 +2298,35 @@ FIO_determineDstName(const char* srcFileName, const char* outDirName)
|
||||
static size_t dfnbCapacity = 0;
|
||||
static char* dstFileNameBuffer = NULL; /* using static allocation : this function cannot be multi-threaded */
|
||||
char* outDirFilename = NULL;
|
||||
|
||||
const char* SUFFIX_LIST = ZSTD_EXTENSION "/" TZSTD_EXTENSION
|
||||
#ifdef ZSTD_GZDECOMPRESS
|
||||
"/" GZ_EXTENSION "/" TGZ_EXTENSION
|
||||
#endif
|
||||
#ifdef ZSTD_LZMADECOMPRESS
|
||||
"/" XZ_EXTENSION "/" LZMA_EXTENSION "/" TXZ_EXTENSION
|
||||
#endif
|
||||
#ifdef ZSTD_LZ4DECOMPRESS
|
||||
"/" LZ4_EXTENSION "/" TLZ4_EXTENSION
|
||||
#endif
|
||||
;
|
||||
|
||||
size_t sfnSize = strlen(srcFileName);
|
||||
size_t suffixSize;
|
||||
|
||||
const char* const suffixPtr = strrchr(srcFileName, '.');
|
||||
if (suffixPtr == NULL) {
|
||||
DISPLAYLEVEL(1, "zstd: %s: unknown suffix -- ignored \n",
|
||||
srcFileName);
|
||||
DISPLAYLEVEL(1, "zstd: %s: missing suffix (%s expected). Can't derive the output file name so specify it with -o dstFileName. -- ignored \n",
|
||||
srcFileName, SUFFIX_LIST);
|
||||
return NULL;
|
||||
}
|
||||
suffixSize = strlen(suffixPtr);
|
||||
|
||||
/* check suffix is authorized */
|
||||
if (sfnSize <= suffixSize
|
||||
|| ( strcmp(suffixPtr, ZSTD_EXTENSION)
|
||||
#ifdef ZSTD_GZDECOMPRESS
|
||||
&& strcmp(suffixPtr, GZ_EXTENSION)
|
||||
#endif
|
||||
#ifdef ZSTD_LZMADECOMPRESS
|
||||
&& strcmp(suffixPtr, XZ_EXTENSION)
|
||||
&& strcmp(suffixPtr, LZMA_EXTENSION)
|
||||
#endif
|
||||
#ifdef ZSTD_LZ4DECOMPRESS
|
||||
&& strcmp(suffixPtr, LZ4_EXTENSION)
|
||||
#endif
|
||||
) ) {
|
||||
const char* suffixlist = ZSTD_EXTENSION
|
||||
#ifdef ZSTD_GZDECOMPRESS
|
||||
"/" GZ_EXTENSION
|
||||
#endif
|
||||
#ifdef ZSTD_LZMADECOMPRESS
|
||||
"/" XZ_EXTENSION "/" LZMA_EXTENSION
|
||||
#endif
|
||||
#ifdef ZSTD_LZ4DECOMPRESS
|
||||
"/" LZ4_EXTENSION
|
||||
#endif
|
||||
;
|
||||
DISPLAYLEVEL(1, "zstd: %s: unknown suffix (%s expected) -- ignored \n",
|
||||
srcFileName, suffixlist);
|
||||
|| (strstr(SUFFIX_LIST, suffixPtr) == NULL)) {
|
||||
DISPLAYLEVEL(1, "zstd: %s: unknown suffix (%s expected). Can't derive the output file name so specify it with -o dstFileName. -- ignored \n",
|
||||
srcFileName, SUFFIX_LIST);
|
||||
return NULL;
|
||||
}
|
||||
if (outDirName) {
|
||||
@ -2355,13 +2346,23 @@ FIO_determineDstName(const char* srcFileName, const char* outDirName)
|
||||
|
||||
/* return dst name == src name truncated from suffix */
|
||||
assert(dstFileNameBuffer != NULL);
|
||||
size_t dstFileNameEndPos = sfnSize - suffixSize;
|
||||
if (outDirFilename) {
|
||||
memcpy(dstFileNameBuffer, outDirFilename, sfnSize - suffixSize);
|
||||
memcpy(dstFileNameBuffer, outDirFilename, dstFileNameEndPos);
|
||||
free(outDirFilename);
|
||||
} else {
|
||||
memcpy(dstFileNameBuffer, srcFileName, sfnSize - suffixSize);
|
||||
memcpy(dstFileNameBuffer, srcFileName, dstFileNameEndPos);
|
||||
}
|
||||
dstFileNameBuffer[sfnSize-suffixSize] = '\0';
|
||||
/* The short tar extensions tzst, tgz, txz and tlz4 files should have "tar" extension on decompression
|
||||
* To check that the file is one of them we can check that it starts with "t"
|
||||
*/
|
||||
if (suffixPtr[1] == 't') {
|
||||
dstFileNameBuffer[dstFileNameEndPos++] = '.';
|
||||
dstFileNameBuffer[dstFileNameEndPos++] = 't';
|
||||
dstFileNameBuffer[dstFileNameEndPos++] = 'a';
|
||||
dstFileNameBuffer[dstFileNameEndPos++] = 'r';
|
||||
}
|
||||
dstFileNameBuffer[dstFileNameEndPos] = '\0';
|
||||
return dstFileNameBuffer;
|
||||
|
||||
/* note : dstFileNameBuffer memory is not going to be free */
|
||||
|
@ -32,9 +32,13 @@ extern "C" {
|
||||
#endif
|
||||
#define LZMA_EXTENSION ".lzma"
|
||||
#define XZ_EXTENSION ".xz"
|
||||
#define TXZ_EXTENSION ".txz"
|
||||
#define GZ_EXTENSION ".gz"
|
||||
#define TGZ_EXTENSION ".tgz"
|
||||
#define ZSTD_EXTENSION ".zst"
|
||||
#define TZSTD_EXTENSION ".tzst"
|
||||
#define LZ4_EXTENSION ".lz4"
|
||||
#define TLZ4_EXTENSION ".tlz4"
|
||||
|
||||
|
||||
/*-*************************************
|
||||
|
Loading…
Reference in New Issue
Block a user