[FFmpeg-cvslog] file: Fallback to stat() based file_check() when access() or its named flags are unavailable.
Michael Niedermayer
git at videolan.org
Tue Nov 27 05:08:43 CET 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Nov 27 04:57:18 2012 +0100| [16ef48c37fadb251a76dac8e000be5caa6ffd25f] | committer: Michael Niedermayer
file: Fallback to stat() based file_check() when access() or its named flags are unavailable.
Should fix compilation on native windows
We could also use _access() and literal numbers as flags but i cant test it
and the compilation failure should be fixed ASAP
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=16ef48c37fadb251a76dac8e000be5caa6ffd25f
---
libavformat/file.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libavformat/file.c b/libavformat/file.c
index 44a1558..840d368 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -85,6 +85,7 @@ static int file_get_handle(URLContext *h)
static int file_check(URLContext *h, int mask)
{
+#if defined(HAVE_ACCESS) && defined(R_OK)
int ret = 0;
if (access(h->filename, F_OK) < 0)
return AVERROR(errno);
@@ -94,6 +95,15 @@ static int file_check(URLContext *h, int mask)
if (mask&AVIO_FLAG_WRITE)
if (access(h->filename, W_OK) >= 0)
ret |= AVIO_FLAG_WRITE;
+#else
+ 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;
+#endif
return ret;
}
More information about the ffmpeg-cvslog
mailing list