From 7222b0b5ac62421a9f2b7514e519a9a691300a0d Mon Sep 17 00:00:00 2001 From: nu774 Date: Sun, 6 Jan 2013 13:41:31 +0900 Subject: [PATCH] use fstat() to test seekability of input file --- src/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 41ea731..e12e8fb 100644 --- a/src/main.c +++ b/src/main.c @@ -13,7 +13,14 @@ #include #include #include +#include #include +#if HAVE_UNISTD_H +#include +#endif +#ifdef _WIN32 +#include +#endif #include "compat.h" #include "wav_reader.h" #include "aacenc.h" @@ -470,6 +477,7 @@ int main(int argc, char **argv) const pcm_sample_description_t *sample_format; int downsampled_timescale = 0; int frame_count = 0; + struct stat stb = { 0 }; setlocale(LC_CTYPE, ""); setbuf(stderr, 0); @@ -483,7 +491,7 @@ int main(int argc, char **argv) goto END; } - if (ifp == stdin) + if (fstat(fileno(ifp), &stb) == 0 && (stb.st_mode & S_IFMT) != S_IFREG) wav_io.seek = 0; if ((wavf = wav_open(&wav_io, ifp, params.ignore_length)) == 0) { -- 2.30.2