Mercurial > audlegacy
changeset 3142:e8f2b130e59e trunk
add vfs_is_remote() and vfs_is_streaming().
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Sun, 22 Jul 2007 12:12:08 +0900 |
parents | a2f1d831065f |
children | 34b4b7c9bcd4 |
files | src/audacious/vfs.c src/audacious/vfs.h |
diffstat | 2 files changed, 76 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/vfs.c Sun Jul 22 12:08:08 2007 +0900 +++ b/src/audacious/vfs.c Sun Jul 22 12:12:08 2007 +0900 @@ -409,3 +409,75 @@ return in; } + +/** + * vfs_is_remote: + * @path: A path to test. + * + * Tests if a path is remote uri. + * + * Return value: TRUE if the file is remote, otherwise FALSE. + **/ +gboolean +vfs_is_remote(const gchar * path) +{ + VFSConstructor *vtable = NULL; + GList *node; + gchar *decpath; + + if (!path) + return FALSE; + + decpath = g_strdup(path); + + for (node = vfs_transports; node != NULL; node = g_list_next(node)) + { + VFSConstructor *vtptr = (VFSConstructor *) node->data; + + if (!strncasecmp(decpath, vtptr->uri_id, strlen(vtptr->uri_id))) + { + vtable = vtptr; + break; + } + } + + /* no transport vtable has been registered, bail. */ + if (vtable == NULL) + { + g_warning("could not open '%s', no transport plugin available", decpath); + return FALSE; + } + + /* check if vtable->uri_id is file:// or not, for now. */ + if(!strncasecmp("file://", vtable->uri_id, strlen(vtable->uri_id))) + return FALSE; + else + return TRUE; +} + +/** + * vfs_is_streaming: + * @file: A #VFSFile object to test. + * + * Tests if a file is associated to streaming. + * + * Return value: TRUE if the file is streaming, otherwise FALSE. + **/ +gboolean +vfs_is_streaming(VFSFile *file) +{ + off_t size = 0; + glong curpos; + + if(!file) + return FALSE; + + curpos = file->base->vfs_ftell_impl(file); + size = file->base->vfs_fsize_impl(file); + file->base->vfs_fseek_impl(file, curpos, SEEK_SET); + + if(size == -1) + return TRUE; + else + return FALSE; +}
--- a/src/audacious/vfs.h Sun Jul 22 12:08:08 2007 +0900 +++ b/src/audacious/vfs.h Sun Jul 22 12:12:08 2007 +0900 @@ -132,6 +132,10 @@ extern void vfs_file_get_contents(const gchar *filename, gchar **buf, gsize *size); +extern gboolean vfs_is_remote(const gchar * path); + +extern gboolean vfs_is_streaming(VFSFile *file); + G_END_DECLS #endif /* VFS_H */