changeset 2688:ac22b2cb6013 trunk

[svn] - Add a vfs_fsize() call to the VFS layer
author ertzing
date Fri, 20 Apr 2007 06:49:07 -0700
parents fcc497f51c16
children 18e69948e8f1
files ChangeLog src/audacious/build_stamp.c src/audacious/vfs.c src/audacious/vfs.h src/audacious/vfs_buffer.c src/audacious/vfs_buffered_file.c
diffstat 6 files changed, 53 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 20 04:49:29 2007 -0700
+++ b/ChangeLog	Fri Apr 20 06:49:07 2007 -0700
@@ -1,3 +1,10 @@
+2007-04-20 11:49:29 +0000  Ralf Ertzinger <ralf@skytale.net>
+  revision [4400]
+  Some more bad escapes
+  trunk/po/sr@Latn.po |    2 +-
+  1 file changed, 1 insertion(+), 1 deletion(-)
+
+
 2007-04-20 11:45:22 +0000  Ralf Ertzinger <ralf@skytale.net>
   revision [4398]
   Fix some wrong escape sequences
--- a/src/audacious/build_stamp.c	Fri Apr 20 04:49:29 2007 -0700
+++ b/src/audacious/build_stamp.c	Fri Apr 20 06:49:07 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070420-4398";
+const gchar *svn_stamp = "20070420-4400";
--- a/src/audacious/vfs.c	Fri Apr 20 04:49:29 2007 -0700
+++ b/src/audacious/vfs.c	Fri Apr 20 06:49:07 2007 -0700
@@ -303,6 +303,24 @@
 }
 
 /**
+ * vfs_fsize:
+ * @file: #VFSFile object that represents the VFS stream.
+ *
+ * Returns te size of the file
+ *
+ * Return value: On success, the size of the file in bytes.
+ * Otherwise, -1.
+ */
+off_t
+vfs_fsize(VFSFile * file)
+{
+    if (file == NULL)
+        return -1;
+
+    return file->base->vfs_fsize_impl(file);
+}
+
+/**
  * vfs_get_metadata:
  * @file: #VFSFile object that represents the VFS stream.
  * @field: The string constant field name to get.
--- a/src/audacious/vfs.h	Fri Apr 20 04:49:29 2007 -0700
+++ b/src/audacious/vfs.h	Fri Apr 20 06:49:07 2007 -0700
@@ -21,6 +21,7 @@
 
 #include <glib.h>
 #include <stdio.h>
+#include <sys/types.h>
 
 typedef struct _VFSFile VFSFile;
 typedef struct _VFSConstructor VFSConstructor;
@@ -76,6 +77,7 @@
 	glong (*vfs_ftell_impl)(VFSFile *file);
 	gboolean (*vfs_feof_impl)(VFSFile *file);
 	gboolean (*vfs_truncate_impl)(VFSFile *file, glong length);
+	off_t (*vfs_fsize_impl)(VFSFile *file);
 	gchar *(*vfs_get_metadata_impl)(VFSFile *file, const gchar * field);
 };
 
@@ -117,6 +119,8 @@
 
 extern gboolean vfs_truncate(VFSFile * file, glong length);
 
+extern off_t vfs_fsize(VFSFile * file);
+
 extern gchar *vfs_get_metadata(VFSFile * file, const gchar * field);
 
 extern int vfs_fprintf(VFSFile *stream, gchar const *format, ...)
--- a/src/audacious/vfs_buffer.c	Fri Apr 20 04:49:29 2007 -0700
+++ b/src/audacious/vfs_buffer.c	Fri Apr 20 06:49:07 2007 -0700
@@ -185,6 +185,19 @@
     return 0;
 }
 
+off_t
+buffer_vfs_fsize_impl(VFSFile * file)
+{
+    VFSBuffer *handle;
+
+    if (file == NULL)
+        return -1;
+
+    handle = (VFSBuffer *) file->handle;
+
+    return (off_t)handle->end;
+}
+
 VFSConstructor buffer_const = {
 	NULL,			// not a normal VFS class
 	buffer_vfs_fopen_impl,
@@ -198,6 +211,7 @@
 	buffer_vfs_ftell_impl,
 	buffer_vfs_feof_impl,
 	buffer_vfs_truncate_impl,
+	buffer_vfs_fsize_impl,
 	NULL
 };
 
--- a/src/audacious/vfs_buffered_file.c	Fri Apr 20 04:49:29 2007 -0700
+++ b/src/audacious/vfs_buffered_file.c	Fri Apr 20 06:49:07 2007 -0700
@@ -157,6 +157,14 @@
     return 0;
 }
 
+off_t
+buffered_file_vfs_fsize_impl(VFSFile * file)
+{
+    VFSBufferedFile *handle = (VFSBufferedFile *) file->handle;
+
+    return vfs_fsize(handle->which == TRUE ? handle->fd : handle->buffer);
+}
+
 gchar *
 buffered_file_vfs_metadata_impl(VFSFile * file, const gchar * field)
 {
@@ -178,6 +186,7 @@
 	buffered_file_vfs_ftell_impl,
 	buffered_file_vfs_feof_impl,
 	buffered_file_vfs_truncate_impl,
+	buffered_file_vfs_fsize_impl,
 	buffered_file_vfs_metadata_impl
 };