summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-04-17 22:56:19 +0200
committerwm4 <wm4@nowhere>2015-04-17 23:02:14 +0200
commit1d36955f70d27b5de6d323f23b94034221db0890 (patch)
tree21261d593be61fcb69eca1bcfb9b3dbb0d092f7d /stream
parent01cfcd68142d72f4805db9a033cdd63106bae6cc (diff)
downloadmpv-1d36955f70d27b5de6d323f23b94034221db0890.tar.bz2
mpv-1d36955f70d27b5de6d323f23b94034221db0890.tar.xz
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.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream.h1
-rw-r--r--stream/stream_file.c8
2 files changed, 5 insertions, 4 deletions
diff --git a/stream/stream.h b/stream/stream.h
index 387006cb8f..7b4751450c 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -31,6 +31,7 @@
enum streamtype {
STREAMTYPE_GENERIC = 0,
STREAMTYPE_FILE,
+ STREAMTYPE_DIR,
STREAMTYPE_DVB,
STREAMTYPE_DVD,
STREAMTYPE_BLURAY,
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;