static int file_check(URLContext *h, int mask)

{

#if HAVE_ACCESS && defined(R_OK)

    int ret = 0;

    if (access(h->filename, F_OK) < 0)

        return AVERROR(errno);

    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;

#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;

}

static int file_check(URLContext *h, int mask)

{

#if HAVE_ACCESS && defined(R_OK)

    int ret = 0;

    if (access(h->filename, F_OK) < 0)

        return AVERROR(errno);

    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;

#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;

}

static int FUNC_0(URLContext *VAR_0, int VAR_1)

{

#if HAVE_ACCESS && defined(R_OK)

    int VAR_3 = 0;

    if (access(VAR_0->filename, F_OK) < 0)

        return AVERROR(errno);

    if (VAR_1&AVIO_FLAG_READ)

        if (access(VAR_0->filename, R_OK) >= 0)

            VAR_3 |= AVIO_FLAG_READ;

    if (VAR_1&AVIO_FLAG_WRITE)

        if (access(VAR_0->filename, W_OK) >= 0)

            VAR_3 |= AVIO_FLAG_WRITE;

#else

    struct stat VAR_2;

    int VAR_3 = stat(VAR_0->filename, &VAR_2);

    if (VAR_3 < 0)

        return AVERROR(errno);



    VAR_3 |= VAR_2.st_mode&S_IRUSR ? VAR_1&AVIO_FLAG_READ  : 0;

    VAR_3 |= VAR_2.st_mode&S_IWUSR ? VAR_1&AVIO_FLAG_WRITE : 0;

#endif

    return VAR_3;

}

static int FUNC_0(URLContext *VAR_0, int VAR_1)
{ #if HAVE_ACCESS && defined(R_OK)
int VAR_3 = 0; if (access(VAR_0->filename, F_OK) < 0)
return AVERROR(errno); if (VAR_1&AVIO_FLAG_READ)
if (access(VAR_0->filename, R_OK) >= 0)
VAR_3 |= AVIO_FLAG_READ; if (VAR_1&AVIO_FLAG_WRITE)
if (access(VAR_0->filename, W_OK) >= 0)
VAR_3 |= AVIO_FLAG_WRITE; #else
struct stat VAR_2; int VAR_3 = stat(VAR_0->filename, &VAR_2); if (VAR_3 < 0)
return AVERROR(errno); VAR_3 |= VAR_2.st_mode&S_IRUSR ? VAR_1&AVIO_FLAG_READ  : 0; VAR_3 |= VAR_2.st_mode&S_IWUSR ? VAR_1&AVIO_FLAG_WRITE : 0; #endif
return VAR_3; }