X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Ffile.c;h=08c7f8e6dd7c938341f111b50b31debe0dd84b8e;hb=00ed04d6149691a9abf486b2f88172fd6341d801;hp=1d321c42050e31588a411583c4f9578254460ac0;hpb=fb4a12cda4033f2f3d3d1039739f6e0e6f9afb82;p=ffmpeg diff --git a/libavformat/file.c b/libavformat/file.c index 1d321c42050..08c7f8e6dd7 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -73,6 +73,7 @@ typedef struct FileContext { int trunc; int blocksize; int follow; + int seekable; #if HAVE_DIRENT_H DIR *dir; #endif @@ -82,6 +83,7 @@ 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 }, + { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; @@ -173,7 +175,11 @@ static int file_delete(URLContext *h) av_strstart(filename, "file:", &filename); ret = rmdir(filename); - if (ret < 0 && errno == ENOTDIR) + if (ret < 0 && (errno == ENOTDIR +# ifdef _WIN32 + || errno == EINVAL +# endif + )) ret = unlink(filename); if (ret < 0) return AVERROR(errno); @@ -234,6 +240,9 @@ static int file_open(URLContext *h, const char *filename, int flags) if (!h->is_streamed && flags & AVIO_FLAG_WRITE) h->min_packet_size = h->max_packet_size = 262144; + if (c->seekable >= 0) + h->is_streamed = !c->seekable; + return 0; }