44 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
46 # define S_ISFIFO(m) 0
53 # define S_ISLNK(m) (((m) & S_IFLNK) == S_IFLNK)
62 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
64 # define S_ISSOCK(m) 0
112 ret = read(c->
fd, buf, size);
113 if (ret == 0 && c->
follow)
115 return (ret == -1) ?
AVERROR(errno) : ret;
123 ret = write(c->
fd, buf, size);
124 return (ret == -1) ?
AVERROR(errno) : ret;
140 #if HAVE_ACCESS && defined(R_OK)
141 if (access(filename, F_OK) < 0)
144 if (access(filename, R_OK) >= 0)
147 if (access(filename, W_OK) >= 0)
152 ret = stat(filename, &st);
154 ret = win32_stat(filename, &st);
159 ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
160 ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
173 ret = rmdir(filename);
174 if (ret < 0 && errno == ENOTDIR)
175 ret = unlink(filename);
187 const char *filename_src = h_src->
filename;
188 const char *filename_dst = h_dst->
filename;
192 if (rename(filename_src, filename_dst) < 0)
198 #if CONFIG_FILE_PROTOCOL
210 access = O_CREAT | O_RDWR;
214 access = O_CREAT | O_WRONLY;
234 static int64_t file_seek(
URLContext *h, int64_t pos,
int whence)
241 ret = fstat(c->
fd, &st);
242 return ret < 0 ?
AVERROR(errno) : (
S_ISFIFO(st.st_mode) ? 0 : st.st_size);
245 ret = lseek(c->
fd, pos, whence);
247 return ret < 0 ?
AVERROR(errno) : ret;
276 char *fullpath =
NULL;
283 dir = readdir(c->dir);
288 }
while (!strcmp(dir->d_name,
".") || !strcmp(dir->d_name,
".."));
293 if (!lstat(fullpath, &st)) {
294 if (S_ISDIR(st.st_mode))
298 else if (S_ISCHR(st.st_mode))
300 else if (S_ISBLK(st.st_mode))
306 else if (S_ISREG(st.st_mode))
311 (*next)->group_id = st.st_gid;
312 (*next)->user_id = st.st_uid;
313 (*next)->size = st.st_size;
314 (*next)->filemode = st.st_mode & 0777;
315 (*next)->modification_timestamp = INT64_C(1000000) * st.st_mtime;
316 (*next)->access_timestamp = INT64_C(1000000) * st.st_atime;
317 (*next)->status_change_timestamp = INT64_C(1000000) * st.st_ctime;
342 .url_open = file_open,
345 .url_seek = file_seek,
346 .url_close = file_close,
352 .priv_data_class = &file_class,
353 .url_open_dir = file_open_dir,
354 .url_read_dir = file_read_dir,
355 .url_close_dir = file_close_dir,
356 .default_whitelist =
"file,crypto"
361 #if CONFIG_PIPE_PROTOCOL
363 static int pipe_open(
URLContext *h,
const char *filename,
int flags)
370 fd = strtol(filename, &
final, 10);
371 if((filename ==
final) || *
final ) {
372 if (flags & AVIO_FLAG_WRITE) {
388 .url_open = pipe_open,
394 .priv_data_class = &pipe_class,
395 .default_whitelist =
"crypto"
#define LIBAVUTIL_VERSION_INT
int is_streamed
true if streamed (no seek possible), default = false
Describes single entry of the directory.
#define AVIO_FLAG_READ
read-only
#define AVIO_FLAG_WRITE
write-only
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
miscellaneous OS support macros and functions.
int avpriv_open(const char *filename, int flags,...)
A wrapper for open() setting O_CLOEXEC.
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
static const uint16_t mask[17]
const URLProtocol ff_pipe_protocol
const URLProtocol ff_file_protocol
common internal API header
static av_always_inline av_const double trunc(double x)
char * av_strdup(const char *s)
Duplicate a string.
Describe the class of an AVClass context structure.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
char * av_append_path_component(const char *path, const char *component)
Append path component to the existing path.
AVIODirEntry * ff_alloc_dir_entry(void)
Allocate directory entry with default values.
char * filename
specified URL
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
unbuffered private I/O API