Revision 31317656

View differences:

libavformat/file.c
95 95
    return close(fd);
96 96
}
97 97

  
98
static int file_check(URLContext *h, int mask)
99
{
100
    struct stat st;
101
    int ret = stat(h->filename, &st);
102
    if (ret < 0)
103
        return AVERROR(errno);
104

  
105
    ret |= st.st_mode&S_IRUSR ? mask&AVIO_RDONLY : 0;
106
    ret |= st.st_mode&S_IWUSR ? mask&AVIO_WRONLY : 0;
107
    ret |= st.st_mode&S_IWUSR && st.st_mode&S_IRUSR ? mask&AVIO_RDWR : 0;
108

  
109
    return ret;
110
}
111

  
98 112
URLProtocol ff_file_protocol = {
99 113
    .name                = "file",
100 114
    .url_open            = file_open,
......
103 117
    .url_seek            = file_seek,
104 118
    .url_close           = file_close,
105 119
    .url_get_file_handle = file_get_handle,
120
    .url_check           = file_check,
106 121
};
107 122

  
108 123
#endif /* CONFIG_FILE_PROTOCOL */
......
137 152
    .url_read            = file_read,
138 153
    .url_write           = file_write,
139 154
    .url_get_file_handle = file_get_handle,
155
    .url_check           = file_check,
140 156
};
141 157

  
142 158
#endif /* CONFIG_PIPE_PROTOCOL */

Also available in: Unified diff