changeset 2424:3e3d34173207 trunk

[svn] - vfs_get_file_contents() implementation. - g_file_get_contents -> vfs_get_file_contents
author nenolod
date Sat, 27 Jan 2007 04:51:25 -0800
parents 3a41eba0ef5d
children 5b1b26db3a37
files ChangeLog src/audacious/util.c src/audacious/vfs.h src/audacious/vfs_common.c
diffstat 4 files changed, 41 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 27 04:39:43 2007 -0800
+++ b/ChangeLog	Sat Jan 27 04:51:25 2007 -0800
@@ -1,3 +1,11 @@
+2007-01-27 12:39:43 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [3856]
+  - indentation cleanups
+  
+  trunk/src/audacious/util.c |    6 +++---
+  1 file changed, 3 insertions(+), 3 deletions(-)
+
+
 2007-01-27 12:37:49 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [3854]
   - break out the URL opener UI code
--- a/src/audacious/util.c	Sat Jan 27 04:39:43 2007 -0800
+++ b/src/audacious/util.c	Sat Jan 27 04:51:25 2007 -0800
@@ -406,7 +406,7 @@
             open_buffer = NULL;
         }
 
-        if (!g_file_get_contents(filename, &buffer, &filesize, NULL))
+        if (!vfs_file_get_contents(filename, &buffer, &filesize))
             return NULL;
 
         open_buffer = g_strdup(filename);
--- a/src/audacious/vfs.h	Sat Jan 27 04:39:43 2007 -0800
+++ b/src/audacious/vfs.h	Sat Jan 27 04:51:25 2007 -0800
@@ -120,6 +120,8 @@
 
 extern gboolean vfs_register_transport(VFSConstructor *vtable);
 
+extern void vfs_file_get_contents(const gchar *filename, gchar **buf, gsize *size);
+
 G_END_DECLS
 
 #endif /* VFS_H */
--- a/src/audacious/vfs_common.c	Sat Jan 27 04:39:43 2007 -0800
+++ b/src/audacious/vfs_common.c	Sat Jan 27 04:51:25 2007 -0800
@@ -130,3 +130,33 @@
 
     return rv;
 }
+
+/**
+ * vfs_file_get_contents
+ * @filename: the filename to read in
+ * @buf: pointer to pointer of buffer
+ * @sz: pointer to integer that is the size
+ **/
+void
+vfs_file_get_contents(const gchar *filename, gchar **buf, gsize *size)
+{
+    VFSFile *fd;
+
+    fd = vfs_fopen(filename, "rb");
+
+    if (fd == NULL)
+        return;
+
+    vfs_fseek(fd, 0, SEEK_END);
+    *size = vfs_ftell(fd);
+
+    *buf = g_new(gchar, *size);
+
+    if (*buf == NULL)
+        return;
+
+    vfs_fseek(fd, 0, SEEK_SET);
+    vfs_fread(*buf, 1, *size, fd);
+
+    vfs_fclose(fd);
+}