mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
Merge pull request #3027 from brailovich/dev
fix for -r on empty directory
This commit is contained in:
@ -839,6 +839,7 @@ int main(int argCount, const char* argv[])
|
|||||||
size_t streamSrcSize = 0;
|
size_t streamSrcSize = 0;
|
||||||
size_t targetCBlockSize = 0;
|
size_t targetCBlockSize = 0;
|
||||||
size_t srcSizeHint = 0;
|
size_t srcSizeHint = 0;
|
||||||
|
size_t nbInputFileNames = 0;
|
||||||
int dictCLevel = g_defaultDictCLevel;
|
int dictCLevel = g_defaultDictCLevel;
|
||||||
unsigned dictSelect = g_defaultSelectivityLevel;
|
unsigned dictSelect = g_defaultSelectivityLevel;
|
||||||
#ifndef ZSTD_NODICT
|
#ifndef ZSTD_NODICT
|
||||||
@ -1261,6 +1262,8 @@ int main(int argCount, const char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nbInputFileNames = filenames->tableSize; /* saving number of input files */
|
||||||
|
|
||||||
if (recursive) { /* at this stage, filenameTable is a list of paths, which can contain both files and directories */
|
if (recursive) { /* at this stage, filenameTable is a list of paths, which can contain both files and directories */
|
||||||
UTIL_expandFNT(&filenames, followLinks);
|
UTIL_expandFNT(&filenames, followLinks);
|
||||||
}
|
}
|
||||||
@ -1363,7 +1366,17 @@ int main(int argCount, const char* argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* No input filename ==> use stdin and stdout */
|
/* No input filename ==> use stdin and stdout */
|
||||||
if (filenames->tableSize == 0) UTIL_refFilename(filenames, stdinmark);
|
if (filenames->tableSize == 0) {
|
||||||
|
/* It is possible that the input
|
||||||
|
was a number of empty directories. In this case
|
||||||
|
stdin and stdout should not be used */
|
||||||
|
if (nbInputFileNames > 0 ){
|
||||||
|
DISPLAYLEVEL(1, "please provide correct input file(s) or non-empty directories -- ignored \n");
|
||||||
|
CLEAN_RETURN(0);
|
||||||
|
}
|
||||||
|
UTIL_refFilename(filenames, stdinmark);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(filenames->fileNames[0], stdinmark) && !outFileName)
|
if (!strcmp(filenames->fileNames[0], stdinmark) && !outFileName)
|
||||||
outFileName = stdoutmark; /* when input is stdin, default output is stdout */
|
outFileName = stdoutmark; /* when input is stdin, default output is stdout */
|
||||||
|
|
||||||
|
@ -391,6 +391,11 @@ println "\n===> recursive mode test "
|
|||||||
# combination of -r with empty list of input file
|
# combination of -r with empty list of input file
|
||||||
zstd -c -r < tmp > tmp.zst
|
zstd -c -r < tmp > tmp.zst
|
||||||
|
|
||||||
|
# combination of -r with empty folder
|
||||||
|
mkdir -p tmpEmptyDir
|
||||||
|
zstd -r tmpEmptyDir
|
||||||
|
rm -rf tmpEmptyDir
|
||||||
|
|
||||||
|
|
||||||
println "\n===> file removal"
|
println "\n===> file removal"
|
||||||
zstd -f --rm tmp
|
zstd -f --rm tmp
|
||||||
|
Reference in New Issue
Block a user