summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-08-03 20:33:46 +0300
committerwm4 <wm4@nowhere>2012-08-16 17:16:32 +0200
commit202ea8214ef1db693405b75559868523ca725ac0 (patch)
treed5fc782a79963f18bd10c99d06dbc3a8b0eeca21
parent214edc0ef29104ec0561583318a08e31f384e48e (diff)
downloadmpv-202ea8214ef1db693405b75559868523ca725ac0.tar.bz2
mpv-202ea8214ef1db693405b75559868523ca725ac0.tar.xz
stream_file: print strerror() when failing to open a file
stream_file always printed "File not found" if it could not open a file, even though this could be due to other reasons such as permission problems. Print strerror() information instead. This changes the output for "mplayer /etc/shadow" from File not found: '/etc/shadow' to Cannot open file '/etc/shadow': Permission denied
-rw-r--r--stream/stream_file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 28f8f975ce..dfafb773f0 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -23,6 +23,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
#include "osdep/io.h"
@@ -169,7 +170,8 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
#endif
f=open(filename,m, openmode);
if(f<0) {
- mp_tmsg(MSGT_OPEN,MSGL_ERR,"File not found: '%s'\n",filename);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Cannot open file '%s': %s\n", filename,
+ strerror(errno));
m_struct_free(&stream_opts,opts);
return STREAM_ERROR;
}