Skip to content

Commit

Permalink
Merge pull request #1 from brailovich/brailovich-patch-1
Browse files Browse the repository at this point in the history
fix for error message in recursive mode for an empty folder
  • Loading branch information
brailovich committed Jan 25, 2022
2 parents feaaf7a + 4021b78 commit 62583dc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion programs/zstdcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ int main(int argCount, const char* argv[])
size_t streamSrcSize = 0;
size_t targetCBlockSize = 0;
size_t srcSizeHint = 0;
size_t nbInputFileNames = 0;
int dictCLevel = g_defaultDictCLevel;
unsigned dictSelect = g_defaultSelectivityLevel;
#ifndef ZSTD_NODICT
Expand Down Expand Up @@ -1256,6 +1257,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 */
UTIL_expandFNT(&filenames, followLinks);
}
Expand Down Expand Up @@ -1358,7 +1361,17 @@ int main(int argCount, const char* argv[])
#endif

/* 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(2, "please provide correct input file(s) or non-empty directories -- ignored \n");
CLEAN_RETURN(2);
}
UTIL_refFilename(filenames, stdinmark);
}

if (!strcmp(filenames->fileNames[0], stdinmark) && !outFileName)
outFileName = stdoutmark; /* when input is stdin, default output is stdout */

Expand Down

0 comments on commit 62583dc

Please sign in to comment.