From d5c4dcc59750052a1a95b5185aca3548a5b951de Mon Sep 17 00:00:00 2001 From: Steve Markgraf Date: Wed, 23 May 2018 23:13:14 +0200 Subject: fl2k_file: support reading from stdin Thanks to Ted Yapo for reporting. Signed-off-by: Steve Markgraf --- src/fl2k_file.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/fl2k_file.c b/src/fl2k_file.c index 1d3697d..05db28e 100644 --- a/src/fl2k_file.c +++ b/src/fl2k_file.c @@ -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); -- cgit v1.2.3