From 1d36955f70d27b5de6d323f23b94034221db0890 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 17 Apr 2015 22:56:19 +0200 Subject: player: allow playing directories If a directory is encountered, replace it with its contents in the internal playlist. This is messed into demux_playlist.c, because why not. STREAMTYPE_DIR could be avoided by unconditonally trying opendir() in demux_playlist.c, but it seems nicer not to do weird things like calling it on real files. This does not work on Windows, because msvcrt is retarded. --- stream/stream_file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'stream/stream_file.c') diff --git a/stream/stream_file.c b/stream/stream_file.c index 01e983fa31..83d90b902b 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -238,6 +238,7 @@ static int open_f(stream_t *stream) .fd = -1 }; stream->priv = priv; + stream->type = STREAMTYPE_FILE; bool write = stream->mode == STREAM_WRITE; int m = O_CLOEXEC | (write ? O_RDWR | O_CREAT | O_TRUNC : O_RDONLY); @@ -278,9 +279,9 @@ static int open_f(stream_t *stream) struct stat st; if (fstat(fd, &st) == 0) { if (S_ISDIR(st.st_mode)) { - MP_ERR(stream, "File is a directory: '%s'\n", filename); - close(fd); - return STREAM_ERROR; + stream->type = STREAMTYPE_DIR; + stream->allow_caching = false; + MP_INFO(stream, "This is a directory - adding to playlist.\n"); } #ifndef __MINGW32__ if (S_ISREG(st.st_mode)) { @@ -302,7 +303,6 @@ static int open_f(stream_t *stream) stream->seekable = true; } - stream->type = STREAMTYPE_FILE; stream->fast_skip = true; stream->fill_buffer = fill_buffer; stream->write_buffer = write_buffer; -- cgit v1.2.3