Mercurial > audlegacy-plugins
annotate src/wma/libffwma/file.c @ 3122:5744479b31f4
Show right-click menu on blank areas of playlist (closes #15)
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Wed, 06 May 2009 08:31:28 -0400 |
parents | 3134a0987162 |
children |
rev | line source |
---|---|
878 | 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 "cutils.h" | |
21 #include <fcntl.h> | |
22 #include <unistd.h> | |
23 #include <sys/ioctl.h> | |
24 #include <sys/time.h> | |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1980
diff
changeset
|
25 #include <audlegacy/plugin.h> |
878 | 26 |
27 /* standard file protocol */ | |
28 | |
29 static int file_open(URLContext *h, const char *filename, int flags) | |
30 { | |
31 VFSFile *file; | |
32 | |
33 if (flags & URL_WRONLY) { | |
1978 | 34 file = aud_vfs_fopen(filename, "wb"); |
878 | 35 } else { |
1978 | 36 file = aud_vfs_fopen(filename, "rb"); |
878 | 37 } |
38 | |
39 if (file == NULL) | |
40 return -ENOENT; | |
41 h->priv_data = file; | |
42 return 0; | |
43 } | |
44 | |
45 static int file_read(URLContext *h, unsigned char *buf, int size) | |
46 { | |
47 VFSFile *file; | |
48 file = h->priv_data; | |
1978 | 49 return aud_vfs_fread(buf, 1, size, file); |
878 | 50 } |
51 | |
52 static int file_write(URLContext *h, unsigned char *buf, int size) | |
53 { | |
54 VFSFile *file; | |
55 file = h->priv_data; | |
1978 | 56 return aud_vfs_fwrite(buf, 1, size, file); |
878 | 57 } |
58 | |
59 /* XXX: use llseek */ | |
60 static offset_t file_seek(URLContext *h, offset_t pos, int whence) | |
61 { | |
62 int result = 0; | |
63 VFSFile *file; | |
64 file = h->priv_data; | |
1978 | 65 result = aud_vfs_fseek(file, pos, whence); |
878 | 66 if (result == 0) |
1978 | 67 result = aud_vfs_ftell(file); |
878 | 68 else |
69 result = -1; | |
70 return result; | |
71 } | |
72 | |
73 static int file_close(URLContext *h) | |
74 { | |
75 VFSFile *file; | |
76 file = h->priv_data; | |
1978 | 77 return aud_vfs_fclose(file); |
878 | 78 } |
79 | |
80 URLProtocol file_protocol = { | |
81 "file", | |
82 file_open, | |
83 file_read, | |
84 file_write, | |
85 file_seek, | |
86 file_close, | |
87 NULL | |
88 }; | |
89 |