@@ -254,6 +254,16 @@ static int64_t file_seek(URLContext *h, int64_t pos, int whence)
return ret < 0 ? AVERROR(errno) : ret;
}
+static int file_sync(URLContext *h)
+{
+ if (h->flags & AVIO_FLAG_WRITE) {
+ FileContext *c = h->priv_data;
+ if (fsync(c->fd) < 0)
+ return AVERROR(errno);
+ }
+ return 0;
+}
+
static int file_close(URLContext *h)
{
FileContext *c = h->priv_data;
@@ -353,6 +363,7 @@ const URLProtocol ff_file_protocol = {
.url_close = file_close,
.url_get_file_handle = file_get_handle,
.url_check = file_check,
+ .url_sync = file_sync,
.url_delete = file_delete,
.url_move = file_move,
.priv_data_size = sizeof(FileContext),
@@ -93,6 +93,8 @@ static inline int is_dos_path(const char *path)
#ifndef S_IWUSR
#define S_IWUSR S_IWRITE
#endif
+
+#define fsync(fd) _commit((fd))
#endif
#if CONFIG_NETWORK