+static int file_read(URLContext *h, unsigned char *buf, int size)
+{
+ int fd = (intptr_t) h->priv_data;
+ return read(fd, buf, size);
+}
+
+static int file_write(URLContext *h, const unsigned char *buf, int size)
+{
+ int fd = (intptr_t) h->priv_data;
+ return write(fd, buf, size);
+}
+
+static int file_get_handle(URLContext *h)
+{
+ return (intptr_t) h->priv_data;
+}
+
+static int file_check(URLContext *h, int mask)
+{
+ struct stat st;
+ int ret = stat(h->filename, &st);
+ if (ret < 0)
+ return AVERROR(errno);
+
+ ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
+ ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
+
+ return ret;
+}
+
+#if CONFIG_FILE_PROTOCOL
+