fl2k_file: support reading from stdin

Thanks to Ted Yapo for reporting.

Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
Steve Markgraf 2018-05-23 23:13:14 +02:00
parent 16b102efcd
commit d5c4dcc597
1 changed files with 11 additions and 4 deletions

View File

@ -145,10 +145,17 @@ int main(int argc, char **argv)
if (dev_index < 0)
exit(1);
file = fopen(filename, "rb");
if (!file) {
fprintf(stderr, "Failed to open %s\n", filename);
goto out;
if (strcmp(filename, "-") == 0) { /* Read samples from stdin */
file = stdin;
#ifdef _WIN32
_setmode(_fileno(stdin), _O_BINARY);
#endif
} else {
file = fopen(filename, "rb");
if (!file) {
fprintf(stderr, "Failed to open %s\n", filename);
return -ENOENT;
}
}
txbuf = malloc(FL2K_BUF_LEN);