61 return read(c->
fd, buf, size);
67 return write(c->
fd, buf, size);
89 #if CONFIG_FILE_PROTOCOL
99 if (flags & AVIO_FLAG_WRITE && flags & AVIO_FLAG_READ) {
100 access = O_CREAT | O_RDWR;
103 }
else if (flags & AVIO_FLAG_WRITE) {
104 access = O_CREAT | O_WRONLY;
113 fd = open(filename, access, 0666);
121 static int64_t file_seek(
URLContext *h, int64_t pos,
int whence)
126 if (whence == AVSEEK_SIZE) {
129 ret = fstat(c->
fd, &st);
130 return ret < 0 ?
AVERROR(errno) : st.st_size;
133 ret = lseek(c->
fd, pos, whence);
135 return ret < 0 ?
AVERROR(errno) : ret;
146 .url_open = file_open,
149 .url_seek = file_seek,
150 .url_close = file_close,
154 .priv_data_class = &file_class,
159 #if CONFIG_PIPE_PROTOCOL
161 static int pipe_open(
URLContext *h,
const char *filename,
int flags)
168 fd = strtol(filename, &
final, 10);
169 if((filename ==
final) || *
final ) {
170 if (flags & AVIO_FLAG_WRITE) {
177 setmode(fd, O_BINARY);
186 .url_open = pipe_open,