Skip to content

Commit 62583dc

Browse files
authored
Merge pull request #1 from brailovich/brailovich-patch-1
fix for error message in recursive mode for an empty folder
2 parents feaaf7a + 4021b78 commit 62583dc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

programs/zstdcli.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ int main(int argCount, const char* argv[])
834834
size_t streamSrcSize = 0;
835835
size_t targetCBlockSize = 0;
836836
size_t srcSizeHint = 0;
837+
size_t nbInputFileNames = 0;
837838
int dictCLevel = g_defaultDictCLevel;
838839
unsigned dictSelect = g_defaultSelectivityLevel;
839840
#ifndef ZSTD_NODICT
@@ -1256,6 +1257,8 @@ int main(int argCount, const char* argv[])
12561257
}
12571258
}
12581259

1260+
nbInputFileNames = filenames->tableSize; /* saving number of input files */
1261+
12591262
if (recursive) { /* at this stage, filenameTable is a list of paths, which can contain both files and directories */
12601263
UTIL_expandFNT(&filenames, followLinks);
12611264
}
@@ -1358,7 +1361,17 @@ int main(int argCount, const char* argv[])
13581361
#endif
13591362

13601363
/* No input filename ==> use stdin and stdout */
1361-
if (filenames->tableSize == 0) UTIL_refFilename(filenames, stdinmark);
1364+
if (filenames->tableSize == 0) {
1365+
/* It is possible that the input
1366+
was a number of empty directories. In this case
1367+
stdin and stdout should not be used */
1368+
if (nbInputFileNames > 0 ){
1369+
DISPLAYLEVEL(2, "please provide correct input file(s) or non-empty directories -- ignored \n");
1370+
CLEAN_RETURN(2);
1371+
}
1372+
UTIL_refFilename(filenames, stdinmark);
1373+
}
1374+
13621375
if (!strcmp(filenames->fileNames[0], stdinmark) && !outFileName)
13631376
outFileName = stdoutmark; /* when input is stdin, default output is stdout */
13641377

0 commit comments

Comments
 (0)