mirror of
https://github.com/mpv-player/mpv
synced 2024-12-22 14:52:43 +00:00
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
This commit is contained in:
parent
c1287003c0
commit
650e8147c1
@ -1759,11 +1759,13 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf)
|
|||||||
|
|
||||||
if (input_conf->in_file) {
|
if (input_conf->in_file) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(input_conf->in_file, &st))
|
int mode = O_RDONLY;
|
||||||
mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't stat %s: %s\n", input_conf->in_file, strerror(errno));
|
// Use RDWR for FIFOs to ensure they stay open over multiple accesses.
|
||||||
else {
|
// Note that on Windows stat may fail for named pipes, but due to how the
|
||||||
int in_file_fd = open(input_conf->in_file,
|
// API works, using RDONLY should be ok.
|
||||||
S_ISFIFO(st.st_mode) ? O_RDWR : O_RDONLY);
|
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)
|
if(in_file_fd >= 0)
|
||||||
mp_input_add_cmd_fd(ictx, in_file_fd, 1, NULL,
|
mp_input_add_cmd_fd(ictx, in_file_fd, 1, NULL,
|
||||||
(mp_close_func_t)close);
|
(mp_close_func_t)close);
|
||||||
@ -1771,7 +1773,6 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf)
|
|||||||
mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't open %s: %s\n",
|
mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't open %s: %s\n",
|
||||||
input_conf->in_file, strerror(errno));
|
input_conf->in_file, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ictx;
|
return ictx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user