summaryrefslogtreecommitdiff
path: root/libavformat/file.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-19 14:41:19 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-19 14:41:19 +0100
commit90eb24996913238e1ad23d412fa3fa0fd93243c0 (patch)
treed6c2a3a6e91add4e2b6ccc9e7904e1c34898990e /libavformat/file.c
parent13406b6124a5120ad029476119b3cdc010fdf0b7 (diff)
parent933dec0e29ec4d2cb83474279a6c52d62fdb7310 (diff)
downloadffmpeg-90eb24996913238e1ad23d412fa3fa0fd93243c0.tar.gz
Merge commit '933dec0e29ec4d2cb83474279a6c52d62fdb7310'
* commit '933dec0e29ec4d2cb83474279a6c52d62fdb7310': file: Add an option for following a file that is being written Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat/file.c')
-rw-r--r--libavformat/file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavformat/file.c b/libavformat/file.c
index f37db1a88d..5765ce7e48 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -72,6 +72,7 @@ typedef struct FileContext {
int fd;
int trunc;
int blocksize;
+ int follow;
#if HAVE_DIRENT_H
DIR *dir;
#endif
@@ -80,6 +81,7 @@ typedef struct FileContext {
static const AVOption file_options[] = {
{ "truncate", "truncate existing files on write", offsetof(FileContext, trunc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
{ "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+ { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
{ NULL }
};
@@ -108,6 +110,8 @@ static int file_read(URLContext *h, unsigned char *buf, int size)
int ret;
size = FFMIN(size, c->blocksize);
ret = read(c->fd, buf, size);
+ if (ret == 0 && c->follow)
+ return AVERROR(EAGAIN);
return (ret == -1) ? AVERROR(errno) : ret;
}