mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
109268c826
commit
407921072f
|
@ -85,14 +85,15 @@ static int file_get_handle(URLContext *h)
|
||||||
|
|
||||||
static int file_check(URLContext *h, int mask)
|
static int file_check(URLContext *h, int mask)
|
||||||
{
|
{
|
||||||
struct stat st;
|
int ret = 0;
|
||||||
int ret = stat(h->filename, &st);
|
if (access(h->filename, F_OK) < 0)
|
||||||
if (ret < 0)
|
|
||||||
return AVERROR(errno);
|
return AVERROR(errno);
|
||||||
|
if (mask&AVIO_FLAG_READ)
|
||||||
ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
|
if (access(h->filename, R_OK) >= 0)
|
||||||
ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
|
ret |= AVIO_FLAG_READ;
|
||||||
|
if (mask&AVIO_FLAG_WRITE)
|
||||||
|
if (access(h->filename, W_OK) >= 0)
|
||||||
|
ret |= AVIO_FLAG_WRITE;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue