summaryrefslogtreecommitdiff
path: root/vfs_stdio.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-10-01 22:17:34 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-10-01 22:17:34 +0200
commit8d67c4ea1f4171227e5dfb1842cffcde1693dac0 (patch)
treedce9d9e8ccbf8542570b24c2bd31962c503e86be /vfs_stdio.c
parent9681613d71b853064735db49fd5715b6cea675ae (diff)
added http filesize fetching (allows mp3 duration calc, etc)
Diffstat (limited to 'vfs_stdio.c')
-rw-r--r--vfs_stdio.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/vfs_stdio.c b/vfs_stdio.c
index 9d63c141..903f2af0 100644
--- a/vfs_stdio.c
+++ b/vfs_stdio.c
@@ -77,6 +77,17 @@ stdio_rewind (DB_FILE *stream) {
rewind (((STDIO_FILE *)stream)->stream);
}
+static int64_t
+stdio_getlength (DB_FILE *stream) {
+ assert (stream);
+ STDIO_FILE *f = (STDIO_FILE *)stream;
+ size_t pos = ftell (f->stream);
+ fseek (f->stream, 0, SEEK_END);
+ size_t sz = ftell (f->stream);
+ fseek (f->stream, pos, SEEK_SET);
+ return sz;
+}
+
// standard stdio vfs
static DB_vfs_t plugin = {
DB_PLUGIN_SET_API_VERSION
@@ -93,6 +104,7 @@ static DB_vfs_t plugin = {
.seek = stdio_seek,
.tell = stdio_tell,
.rewind = stdio_rewind,
+ .getlength = stdio_getlength,
.scheme_names = NULL // this is NULL because that's a fallback vfs, used when no other matching vfs plugin found
};