Allow Invoking zstd --list When stdin is not a tty

Also now returns an error when no inputs are given.

New proposed behavior:

```
felix@odin:~/prog/zstd (list-stdin-check)$ ./zstd -l; echo $?
No files given
1
felix@odin:~/prog/zstd (list-stdin-check)$ ./zstd -l Makefile.zst; echo $?
Frames  Skips  Compressed  Uncompressed  Ratio  Check  Filename
     1      0     3.08 KB      10.92 KB  3.544  XXH64  Makefile.zst
0
felix@odin:~/prog/zstd (list-stdin-check)$ ./zstd -l <Makefile.zst; echo $?
zstd: --list does not support reading from standard input
No files given
1
felix@odin:~/prog/zstd (list-stdin-check)$ ./zstd -l Makefile.zst <Makefile.zst; echo $?
Frames  Skips  Compressed  Uncompressed  Ratio  Check  Filename
     1      0     3.08 KB      10.92 KB  3.544  XXH64  Makefile.zst
0
felix@odin:~/prog/zstd (list-stdin-check)$
```
This commit is contained in:
W. Felix Handte 2018-06-29 15:33:44 -04:00
parent a2c3a4cd0e
commit 712a9fd972

View File

@ -2017,21 +2017,25 @@ static int FIO_listFile(fileInfo_t* total, const char* inFileName, int displayLe
} }
int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel){ int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel){
unsigned u;
if (!IS_CONSOLE(stdin)) { for (u=0; u<numFiles;u++) {
DISPLAYOUT("zstd: --list does not support reading from standard input\n"); if (!strcmp (filenameTable[u], stdinmark)) {
return 1; DISPLAYOUT("zstd: --list does not support reading from standard input\n");
return 1;
}
} }
if (numFiles == 0) { if (numFiles == 0) {
if (!IS_CONSOLE(stdin)) {
DISPLAYOUT("zstd: --list does not support reading from standard input\n");
}
DISPLAYOUT("No files given\n"); DISPLAYOUT("No files given\n");
return 0; return 1;
} }
if (displayLevel <= 2) { if (displayLevel <= 2) {
DISPLAYOUT("Frames Skips Compressed Uncompressed Ratio Check Filename\n"); DISPLAYOUT("Frames Skips Compressed Uncompressed Ratio Check Filename\n");
} }
{ int error = 0; { int error = 0;
unsigned u;
fileInfo_t total; fileInfo_t total;
memset(&total, 0, sizeof(total)); memset(&total, 0, sizeof(total));
total.usesCheck = 1; total.usesCheck = 1;