Mercurial > audlegacy-plugins
annotate src/ffmpeg/libavformat/file.c @ 854:aac49941ee8f trunk
[svn] statusicon 0.3: alternative right-click menu with simple playback control commands
| author | giacomo |
|---|---|
| date | Wed, 14 Mar 2007 07:44:00 -0700 |
| parents | 11278fe4764b |
| children |
| rev | line source |
|---|---|
| 808 | 1 /* |
| 2 * Buffered file io for ffmpeg system | |
| 3 * Copyright (c) 2001 Fabrice Bellard | |
| 4 * | |
| 5 * This library is free software; you can redistribute it and/or | |
| 6 * modify it under the terms of the GNU Lesser General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2 of the License, or (at your option) any later version. | |
| 9 * | |
| 10 * This library is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 * Lesser General Public License for more details. | |
| 14 * | |
| 15 * You should have received a copy of the GNU Lesser General Public | |
| 16 * License along with this library; if not, write to the Free Software | |
| 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 18 */ | |
| 19 #include "avformat.h" | |
| 20 #include <fcntl.h> | |
| 21 #include <unistd.h> | |
| 22 #include <sys/ioctl.h> | |
| 23 #include <sys/time.h> | |
| 24 #include "audacious/vfs.h" | |
| 25 | |
| 26 /* standard file protocol */ | |
| 27 | |
| 28 static int file_open(URLContext *h, const char *filename, int flags) | |
| 29 { | |
| 30 VFSFile *file; | |
| 31 | |
| 32 strstart(filename, "file:", &filename); | |
| 33 | |
| 34 if (flags & URL_WRONLY) { | |
| 35 file = vfs_fopen(filename, "wb"); | |
| 36 } else { | |
| 37 file = vfs_fopen(filename, "rb"); | |
| 38 } | |
| 39 | |
| 40 if (file == NULL) | |
| 41 return -ENOENT; | |
| 42 h->priv_data = file; | |
| 43 return 0; | |
| 44 } | |
| 45 | |
| 46 static int file_read(URLContext *h, unsigned char *buf, int size) | |
| 47 { | |
| 48 VFSFile *file; | |
| 49 file = h->priv_data; | |
| 50 return vfs_fread(buf, 1, size, file); | |
| 51 } | |
| 52 | |
| 53 static int file_write(URLContext *h, unsigned char *buf, int size) | |
| 54 { | |
| 55 VFSFile *file; | |
| 56 file = h->priv_data; | |
| 57 return vfs_fwrite(buf, 1, size, file); | |
| 58 } | |
| 59 | |
| 60 /* XXX: use llseek */ | |
| 61 static offset_t file_seek(URLContext *h, offset_t pos, int whence) | |
| 62 { | |
| 63 int result = 0; | |
| 64 VFSFile *file; | |
| 65 file = h->priv_data; | |
| 66 result = vfs_fseek(file, pos, whence); | |
|
847
11278fe4764b
[svn] - if (result >= 0) return the result of ftell, otherwise return -1.
nenolod
parents:
814
diff
changeset
|
67 if (result >= 0) |
| 808 | 68 result = vfs_ftell(file); |
| 69 else | |
| 70 result = -1; | |
| 71 return result; | |
| 72 } | |
| 73 | |
| 74 static int file_close(URLContext *h) | |
| 75 { | |
| 76 VFSFile *file; | |
| 77 file = h->priv_data; | |
| 78 return vfs_fclose(file); | |
| 79 } | |
| 80 | |
| 81 URLProtocol file_protocol = { | |
| 82 "file", | |
| 83 file_open, | |
| 84 file_read, | |
| 85 file_write, | |
| 86 file_seek, | |
| 87 file_close, | |
| 88 NULL | |
| 89 }; | |
| 90 |
