diff src/audacious/vfs_common.c @ 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 3149d4b1a9a9
children 72cb1cbb578b f1c756f39e6c
line wrap: on
line diff
--- 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);
+}