X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Ffile.c;h=cca9ec1a06478cbeff51e6ac6b9414cca3715cf1;hb=298a587f447fbc9103f66a50b8433aab977afc9b;hp=6a3ed5acb07b30897b20874d9e77f7ba3f52d099;hpb=59d96941f0285a501989d5f2c9b69be0a1393ed5;p=ffmpeg diff --git a/libavformat/file.c b/libavformat/file.c index 6a3ed5acb07..cca9ec1a064 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -1,5 +1,5 @@ /* - * Buffered file io for ffmpeg system + * buffered file I/O * Copyright (c) 2001 Fabrice Bellard * * This file is part of Libav. @@ -51,6 +51,19 @@ static int file_get_handle(URLContext *h) return (intptr_t) h->priv_data; } +static int file_check(URLContext *h, int mask) +{ + 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; + + return ret; +} + #if CONFIG_FILE_PROTOCOL static int file_open(URLContext *h, const char *filename, int flags) @@ -95,19 +108,6 @@ static int file_close(URLContext *h) return close(fd); } -static int file_check(URLContext *h, int mask) -{ - 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; - - return ret; -} - URLProtocol ff_file_protocol = { .name = "file", .url_open = file_open,