diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-10-17 08:58:40 +0000 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-11-02 04:18:37 +0200 |
commit | 650e8147c101769ffe921d1f59b997e892e47a6d (patch) | |
tree | 6caf0130bb985f8383a4417c8313c2ce58187e3f | |
parent | c1287003c0df123e3b00bd5e4dcfca146366a3d9 (diff) | |
download | mpv-650e8147c101769ffe921d1f59b997e892e47a6d.tar.bz2 mpv-650e8147c101769ffe921d1f59b997e892e47a6d.tar.xz |
input: try to open "-input -file=" file even if stat() fails
Do not fail opening a -input file= file just because stat failed, but try
to call "open" in any case.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32497 b3059339-0415-0410-9bf9-f77b7e298cf2
Make code clearer by putting the "special case hack" inside the if.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32499 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | input/input.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/input/input.c b/input/input.c index 8651e83fbc..c366ca76e4 100644 --- a/input/input.c +++ b/input/input.c @@ -1759,18 +1759,19 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf) if (input_conf->in_file) { struct stat st; - if (stat(input_conf->in_file, &st)) - mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't stat %s: %s\n", input_conf->in_file, strerror(errno)); - else { - int in_file_fd = open(input_conf->in_file, - S_ISFIFO(st.st_mode) ? O_RDWR : O_RDONLY); - if(in_file_fd >= 0) - mp_input_add_cmd_fd(ictx, in_file_fd, 1, NULL, - (mp_close_func_t)close); - else - mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't open %s: %s\n", - input_conf->in_file, strerror(errno)); - } + int mode = O_RDONLY; + // Use RDWR for FIFOs to ensure they stay open over multiple accesses. + // Note that on Windows stat may fail for named pipes, but due to how the + // API works, using RDONLY should be ok. + if (stat(input_conf->in_file, &st) == 0 && S_ISFIFO(st.st_mode)) + mode = O_RDWR; + int in_file_fd = open(input_conf->in_file, mode); + if(in_file_fd >= 0) + mp_input_add_cmd_fd(ictx, in_file_fd, 1, NULL, + (mp_close_func_t)close); + else + mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't open %s: %s\n", + input_conf->in_file, strerror(errno)); } return ictx; } |