40 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
42 # define S_ISFIFO(m) 0
69 int r = read(c->
fd, buf, size);
76 int r = write(c->
fd, buf, size);
88 #if HAVE_ACCESS && defined(R_OK)
104 ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
105 ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
110 #if CONFIG_FILE_PROTOCOL
122 access = O_CREAT | O_RDWR;
126 access = O_CREAT | O_WRONLY;
135 fd = open(filename, access, 0666);
146 static int64_t file_seek(
URLContext *h, int64_t pos,
int whence)
153 ret = fstat(c->
fd, &st);
154 return ret < 0 ?
AVERROR(errno) : (
S_ISFIFO(st.st_mode) ? 0 : st.st_size);
157 ret = lseek(c->
fd, pos, whence);
159 return ret < 0 ?
AVERROR(errno) : ret;
170 .url_open = file_open,
173 .url_seek = file_seek,
174 .url_close = file_close,
178 .priv_data_class = &file_class,
183 #if CONFIG_PIPE_PROTOCOL
185 static int pipe_open(
URLContext *h,
const char *filename,
int flags)
192 fd = strtol(filename, &
final, 10);
193 if((filename ==
final) || *
final ) {
194 if (flags & AVIO_FLAG_WRITE) {
201 setmode(fd, O_BINARY);
210 .url_open = pipe_open,