file_check() is not only used by the file protocol, adjust #ifdef accordingly.
Unified · Split
| @@ -51,6 +51,19 @@ static int file_get_handle(URLContext *h) · 50 unmodified lines | |||
| 51 | return (intptr_t) h->priv_data; | 51 | return (intptr_t) h->priv_data; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | static int file_check(URLContext *h, int mask) | ||
| 55 | { | ||
| 56 | struct stat st; | ||
| 57 | int ret = stat(h->filename, &st); | ||
| 58 | if (ret < 0) | ||
| 59 | return AVERROR(errno); | ||
| 60 | |||
| 61 | ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0; | ||
| 62 | ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0; | ||
| 63 | |||
| 64 | return ret; | ||
| 65 | } | ||
| 66 | |||
| 54 | #if CONFIG_FILE_PROTOCOL | 67 | #if CONFIG_FILE_PROTOCOL |
| 55 | 68 | ||
| 56 | static int file_open(URLContext *h, const char *filename, int flags) | 69 | static int file_open(URLContext *h, const char *filename, int flags) |
| @@ -95,19 +108,6 @@ static int file_close(URLContext *h) · 38 unmodified lines | |||
| 95 | return close(fd); | 108 | return close(fd); |
| 96 | } | 109 | } |
| 97 | 110 | ||
| 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_FLAG_READ : 0; | ||
| 106 | ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0; | ||
| 107 | |||
| 108 | return ret; | ||
| 109 | } | ||
| 110 | |||
| 111 | URLProtocol ff_file_protocol = { | 111 | URLProtocol ff_file_protocol = { |
| 112 | .name = "file", | 112 | .name = "file", |
| 113 | .url_open = file_open, | 113 | .url_open = file_open, |