mirror of
https://github.com/facebook/zstd.git
synced 2025-07-29 11:21:22 +03:00
Merge pull request #1839 from bimbashrestha/named_pipes
Allowing named pipes to go through in zstdcli
This commit is contained in:
@ -520,7 +520,7 @@ static FILE* FIO_openSrcFile(const char* srcFileName)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UTIL_isRegularFile(srcFileName)) {
|
if (!UTIL_isRegularFile(srcFileName) && !UTIL_isFIFO(srcFileName)) {
|
||||||
DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n",
|
DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n",
|
||||||
srcFileName);
|
srcFileName);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -126,6 +126,19 @@ int UTIL_isSameFile(const char* fName1, const char* fName2)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
U32 UTIL_isFIFO(const char* infilename)
|
||||||
|
{
|
||||||
|
/* macro guards, as defined in : https://linux.die.net/man/2/lstat */
|
||||||
|
#if PLATFORM_POSIX_VERSION >= 200112L
|
||||||
|
stat_t statbuf;
|
||||||
|
int r = UTIL_getFileStat(infilename, &statbuf);
|
||||||
|
if (!r && S_ISFIFO(statbuf.st_mode)) return 1;
|
||||||
|
#endif
|
||||||
|
(void)infilename;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
U32 UTIL_isLink(const char* infilename)
|
U32 UTIL_isLink(const char* infilename)
|
||||||
{
|
{
|
||||||
/* macro guards, as defined in : https://linux.die.net/man/2/lstat */
|
/* macro guards, as defined in : https://linux.die.net/man/2/lstat */
|
||||||
|
@ -136,6 +136,7 @@ int UTIL_getFileStat(const char* infilename, stat_t* statbuf);
|
|||||||
int UTIL_isSameFile(const char* file1, const char* file2);
|
int UTIL_isSameFile(const char* file1, const char* file2);
|
||||||
int UTIL_compareStr(const void *p1, const void *p2);
|
int UTIL_compareStr(const void *p1, const void *p2);
|
||||||
|
|
||||||
|
U32 UTIL_isFIFO(const char* infilename);
|
||||||
U32 UTIL_isLink(const char* infilename);
|
U32 UTIL_isLink(const char* infilename);
|
||||||
#define UTIL_FILESIZE_UNKNOWN ((U64)(-1))
|
#define UTIL_FILESIZE_UNKNOWN ((U64)(-1))
|
||||||
U64 UTIL_getFileSize(const char* infilename);
|
U64 UTIL_getFileSize(const char* infilename);
|
||||||
|
@ -1004,7 +1004,7 @@ int main(int argCount, const char* argv[])
|
|||||||
if (!followLinks) {
|
if (!followLinks) {
|
||||||
unsigned u;
|
unsigned u;
|
||||||
for (u=0, fileNamesNb=0; u<filenameIdx; u++) {
|
for (u=0, fileNamesNb=0; u<filenameIdx; u++) {
|
||||||
if (UTIL_isLink(filenameTable[u])) {
|
if (UTIL_isLink(filenameTable[u]) && !UTIL_isFIFO(filenameTable[u])) {
|
||||||
DISPLAYLEVEL(2, "Warning : %s is a symbolic link, ignoring\n", filenameTable[u]);
|
DISPLAYLEVEL(2, "Warning : %s is a symbolic link, ignoring\n", filenameTable[u]);
|
||||||
} else {
|
} else {
|
||||||
filenameTable[fileNamesNb++] = filenameTable[u];
|
filenameTable[fileNamesNb++] = filenameTable[u];
|
||||||
|
@ -1099,4 +1099,14 @@ test -f dictionary
|
|||||||
rm -f tmp* dictionary
|
rm -f tmp* dictionary
|
||||||
|
|
||||||
|
|
||||||
|
println "\n===> zstd fifo named pipe test "
|
||||||
|
head -c 10 /dev/zero > tmp_original
|
||||||
|
mkfifo named_pipe
|
||||||
|
head -c 10 /dev/zero > named_pipe &
|
||||||
|
$ZSTD named_pipe -o tmp_compressed
|
||||||
|
$ZSTD -d -o tmp_decompressed tmp_compressed
|
||||||
|
$DIFF -s tmp_original tmp_decompressed
|
||||||
|
rm -rf tmp*
|
||||||
|
rm -rf named_pipe
|
||||||
|
|
||||||
rm -f tmp*
|
rm -f tmp*
|
||||||
|
Reference in New Issue
Block a user