diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-11-27 02:57:20 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-11-27 03:53:53 +0100 |
commit | 407921072f6db318aea74115c2348aa00728d83a (patch) | |
tree | 4930c4a1d283ad1ef8a982f74746d58ae88ea2f9 | |
parent | 109268c826aeb5fd52792c4ead8d56981868b518 (diff) | |
download | ffmpeg-407921072f6db318aea74115c2348aa00728d83a.tar.gz |
file: fix file_check()
Fixes Ticket1904
This should work on windows, but if not please contact me ASAP
i have another idea on how to solve this without access() if that
really doesnt work on windows.
Strongly based on patch by divVerent
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/file.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libavformat/file.c b/libavformat/file.c index 209957b9d3..44a1558b16 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -85,14 +85,15 @@ static int file_get_handle(URLContext *h) static int file_check(URLContext *h, int mask) { - struct stat st; - int ret = stat(h->filename, &st); - if (ret < 0) + int ret = 0; + if (access(h->filename, F_OK) < 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; - + if (mask&AVIO_FLAG_READ) + if (access(h->filename, R_OK) >= 0) + ret |= AVIO_FLAG_READ; + if (mask&AVIO_FLAG_WRITE) + if (access(h->filename, W_OK) >= 0) + ret |= AVIO_FLAG_WRITE; return ret; } |