summaryrefslogtreecommitdiff
path: root/libavformat/file.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-04-14 03:21:38 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-04-14 03:21:38 +0200
commitc55780dcef1ba87564d8003cded7d045dce9ba34 (patch)
treef685b7150db1c7e0f5e65fb2761f3f8bd843f056 /libavformat/file.c
parentff5278d8f6203a9486c0cd63a3aecef4bc2e4f6f (diff)
parent651b276ef7ad8d89e89bfc94a4232ab6c36f3a8a (diff)
downloadffmpeg-c55780dcef1ba87564d8003cded7d045dce9ba34.tar.gz
Merge remote branch 'qatar/master'
* qatar/master: (32 commits) libopencore-amr, libvo-amrwbenc: Allow enabling DTX via private AVOptions libopencore-amr, libvo-amrwbenc: Only check the bitrate when changed libopencore-amr, libvo-amrwbenc: Find the closest matching bitrate libvo-*: Fix up the long codec names libavcodec: Mark AVCodec->priv_class const swscale: Factorize FAST_BGR2YV12 definition. libvo-aacenc: Only produce extradata if the global header flag is set lavf: postpone removal of public metadata conversion API lavc: postpone removal of request_channels lavc: postpone removal of audioconvert and sample_fmt wrappers lavf: postpone removal of deprecated avio functions libopencore-amr: Cosmetics: Rewrap and align libopencore-amr, libvo-amrbwenc: Rename variables and functions libopencore-amr: Convert commented out debug logging into av_dlog libopencore-amr: Remove an unused state variable libvo-amrwbenc: Don't explicitly store bitrate modes in the bitrate table libopencore-amr: Remove a useless local variable libopencore-amr, libvo-amrwbenc: Make the bitrate/mode mapping array static const libopencore-amr, libvo-amrwbenc: Return proper error codes in most places libopencore-amr: Don't print carriage returns in log messages ... Conflicts: doc/developer.texi libavcodec/avcodec.h libavcodec/libvo-aacenc.c libavcodec/libvo-amrwbenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/file.c')
-rw-r--r--libavformat/file.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libavformat/file.c b/libavformat/file.c
index 64f8782c97..9d28a89327 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -95,6 +95,20 @@ static int file_close(URLContext *h)
return close(fd);
}
+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_RDONLY : 0;
+ ret |= st.st_mode&S_IWUSR ? mask&AVIO_WRONLY : 0;
+ ret |= st.st_mode&S_IWUSR && st.st_mode&S_IRUSR ? mask&AVIO_RDWR : 0;
+
+ return ret;
+}
+
URLProtocol ff_file_protocol = {
.name = "file",
.url_open = file_open,
@@ -103,6 +117,7 @@ URLProtocol ff_file_protocol = {
.url_seek = file_seek,
.url_close = file_close,
.url_get_file_handle = file_get_handle,
+ .url_check = file_check,
};
#endif /* CONFIG_FILE_PROTOCOL */
@@ -137,6 +152,7 @@ URLProtocol ff_pipe_protocol = {
.url_read = file_read,
.url_write = file_write,
.url_get_file_handle = file_get_handle,
+ .url_check = file_check,
};
#endif /* CONFIG_PIPE_PROTOCOL */