From 912e268931c5f1529c620a77f23f5c5709d32e29 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 19 Feb 2012 17:33:36 +0100 Subject: stream: refuse to open directories It's pointless. --- stream/stream_file.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'stream/stream_file.c') diff --git a/stream/stream_file.c b/stream/stream_file.c index 6d436cf6f5..22fdcd7e2e 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -171,6 +171,15 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) { m_struct_free(&stream_opts,opts); return STREAM_ERROR; } +#ifndef __MINGW32__ + struct stat st; + if (fstat(f, &st) == 0 && S_ISDIR(st.st_mode)) { + mp_tmsg(MSGT_OPEN,MSGL_ERR,"File is a directory: '%s'\n",filename); + close(f); + m_struct_free(&stream_opts,opts); + return STREAM_ERROR; + } +#endif } len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); -- cgit v1.2.3