Commit 90eb2499 authored by Derek Buitenhuis's avatar Derek Buitenhuis

Merge commit '933dec0e'

* commit '933dec0e':
  file: Add an option for following a file that is being written
Merged-by: 's avatarDerek Buitenhuis <derek.buitenhuis@gmail.com>
parents 13406b61 933dec0e
......@@ -224,6 +224,17 @@ it, unless special care is taken (tests, customized server configuration
etc.). Different FTP servers behave in different way during seek
operation. ff* tools may produce incomplete content due to server limitations.
This protocol accepts the following options:
@table @option
@item follow
If set to 1, the protocol will retry reading at the end of the file, allowing
reading files that still are being written. In order for this to terminate,
you either need to use the rw_timeout option, or use the interrupt callback
(for API users).
@end table
@section gopher
Gopher protocol.
......
......@@ -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;
}
......
......@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 57
#define LIBAVFORMAT_VERSION_MINOR 34
#define LIBAVFORMAT_VERSION_MICRO 102
#define LIBAVFORMAT_VERSION_MICRO 103
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment