41 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
43 # define S_ISFIFO(m) 0
86 r = read(c->
fd, buf, size);
95 r = write(c->
fd, buf, size);
107 #if HAVE_ACCESS && defined(R_OK)
123 ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
124 ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
129 #if CONFIG_FILE_PROTOCOL
141 access = O_CREAT | O_RDWR;
145 access = O_CREAT | O_WRONLY;
165 static int64_t file_seek(
URLContext *h, int64_t pos,
int whence)
172 ret = fstat(c->
fd, &st);
173 return ret < 0 ?
AVERROR(errno) : (
S_ISFIFO(st.st_mode) ? 0 : st.st_size);
176 ret = lseek(c->
fd, pos, whence);
178 return ret < 0 ?
AVERROR(errno) : ret;
189 .url_open = file_open,
192 .url_seek = file_seek,
193 .url_close = file_close,
197 .priv_data_class = &file_class,
202 #if CONFIG_PIPE_PROTOCOL
204 static int pipe_open(
URLContext *h,
const char *filename,
int flags)
211 fd = strtol(filename, &
final, 10);
212 if((filename ==
final) || *
final ) {
213 if (flags & AVIO_FLAG_WRITE) {
220 setmode(fd, O_BINARY);
229 .url_open = pipe_open,
235 .priv_data_class = &pipe_class,