changeset 339:d19ac60697ec trunk

[svn] - implement virtual class to use VFS through binio - update the places where binio is used directly to use vfs[io]stream instead of bin[io]stream, respectively - make CFileProvider use vfsistream instead of binifstream.
author nenolod
date Wed, 06 Dec 2006 07:37:05 -0800
parents d517fc608e89
children 9e5a7158fa80
files ChangeLog src/adplug/core/Makefile src/adplug/core/binio_virtual.h src/adplug/core/database.cxx src/adplug/core/database.h src/adplug/core/fprovide.cxx
diffstat 6 files changed, 125 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Dec 06 05:09:57 2006 -0800
+++ b/ChangeLog	Wed Dec 06 07:37:05 2006 -0800
@@ -1,3 +1,16 @@
+2006-12-06 13:09:57 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [740]
+  - some more presets
+  - add dynamic colourmap, a scripted colourmap basically.
+  
+  trunk/src/paranormal/builtins.c                          |    2 
+  trunk/src/paranormal/cmaps.c                             |   92 ++++++++++++++-
+  trunk/src/paranormal/presets/Makefile                    |    2 
+  trunk/src/paranormal/presets/nenolod_-_kaliedoscope.pnv  |   28 ++++
+  trunk/src/paranormal/presets/nenolod_-_tunnel_vision.pnv |   30 ++++
+  5 files changed, 153 insertions(+), 1 deletion(-)
+
+
 2006-12-06 06:29:56 +0000  William Pitcock <nenolod@nenolod.net>
   revision [738]
   - note that the dynamic transform is slow
--- a/src/adplug/core/Makefile	Wed Dec 06 05:09:57 2006 -0800
+++ b/src/adplug/core/Makefile	Wed Dec 06 07:37:05 2006 -0800
@@ -18,8 +18,8 @@
 database.h players.h xsm.h adlibemu.h kemuopl.h dro.h dmo.h s3m.h temuopl.h \
 msc.h rix.h adl.h
 
-CXXFLAGS += $(PICFLAGS) $(BINIO_CFLAGS) -I../../../../intl -I../../../.. -Dstricmp=strcasecmp
-CFLAGS += $(PICFLAGS) $(BINIO_CFLAGS) -I../../../../intl -I../../../.. -Dstricmp=strcasecmp
+CXXFLAGS += $(PICFLAGS) $(BINIO_CFLAGS) -I../../../../intl -I../../../.. -Dstricmp=strcasecmp $(BEEP_DEFINES)
+CFLAGS += $(PICFLAGS) $(BINIO_CFLAGS) -I../../../../intl -I../../../.. -Dstricmp=strcasecmp $(BEEP_DEFINES)
 
 OBJECTS = ${SOURCES:.c=.o} ${SOURCES:.cxx=.o}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/adplug/core/binio_virtual.h	Wed Dec 06 07:37:05 2006 -0800
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2006 William Pitcock <nenolod -at- atheme.org>
+ * This code is in the public domain.
+ */
+
+#ifndef __BINIO_VIRTUAL__
+#define __BINIO_VIRTUAL__
+
+#include <binio.h>
+#include <binstr.h>
+
+#include <string>
+
+#include <glib.h>
+#include <audacious/vfs.h>
+
+class vfsistream : public binistream, virtual public binio {
+private:
+	VFSFile *fd;
+
+public:
+	vfsistream() {};
+
+	vfsistream(const char *file) {
+		fd = vfs_fopen(file, "rb");
+	};
+
+	vfsistream(std::string &file) {
+		fd = vfs_fopen(file.c_str(), "rb");
+	};
+
+	~vfsistream() {
+		if (fd != NULL)
+			vfs_fclose(fd);
+	};
+
+	void open(const char *file) {
+		fd = vfs_fopen(file, "rb");
+	};
+
+	void open(std::string &file) {
+		fd = vfs_fopen(file.c_str(), "rb");
+	};
+
+	// XXX: this sucks because binio won't let us do sanity checking
+	Byte getByte(void) {
+		return vfs_getc(fd);
+	};
+
+	void seek(long pos, Offset offs = Set) {
+		vfs_fseek(fd, pos, offs == Set ? SEEK_SET : SEEK_CUR);
+	}
+
+	long pos(void) {
+		return vfs_ftell(fd);
+	}
+};
+
+// XXX: binio sucks and doesn't let us just combine the two.
+class vfsostream : public binostream, virtual public binio {
+private:
+	VFSFile *fd;
+
+public:
+	vfsostream() {};
+
+	vfsostream(const char *file) {
+		fd = vfs_fopen(file, "wb");
+	};
+
+	vfsostream(std::string &file) {
+		fd = vfs_fopen(file.c_str(), "wb");
+	};
+
+	~vfsostream() {
+		if (fd != NULL)
+			vfs_fclose(fd);
+	};
+
+	void open(const char *file) {
+		fd = vfs_fopen(file, "wb");
+	};
+
+	void open(std::string &file) {
+		fd = vfs_fopen(file.c_str(), "wb");
+	};
+
+	// XXX: this sucks because binio won't let us do sanity checking
+	void putByte(Byte b) {
+		vfs_fwrite(&b, 1, 1, fd);
+	};
+
+	void seek(long pos, Offset offs = Set) {
+		vfs_fseek(fd, pos, offs == Set ? SEEK_SET : SEEK_CUR);
+	}
+
+	long pos(void) {
+		return vfs_ftell(fd);
+	}
+};
+
+#endif
--- a/src/adplug/core/database.cxx	Wed Dec 06 05:09:57 2006 -0800
+++ b/src/adplug/core/database.cxx	Wed Dec 06 07:37:05 2006 -0800
@@ -21,8 +21,7 @@
  * Copyright (c) 2002, 2003, 2006 Simon Peter <dn.tlp@gmx.net>
  */
 
-#include <binio.h>
-#include <binfile.h>
+#include "binio_virtual.h"
 #include <string.h>
 
 #include "database.h"
@@ -55,7 +54,7 @@
 
 bool CAdPlugDatabase::load(std::string db_name)
 {
-  binifstream f(db_name);
+  vfsistream f(db_name);
   if(f.error()) return false;
   return load(f);
 }
@@ -86,7 +85,7 @@
 
 bool CAdPlugDatabase::save(std::string db_name)
 {
-  binofstream f(db_name);
+  vfsostream f(db_name);
   if(f.error()) return false;
   return save(f);
 }
--- a/src/adplug/core/database.h	Wed Dec 06 05:09:57 2006 -0800
+++ b/src/adplug/core/database.h	Wed Dec 06 07:37:05 2006 -0800
@@ -26,7 +26,8 @@
 
 #include <iostream>
 #include <string>
-#include <binio.h>
+
+#include "binio_virtual.h"
 
 class CAdPlugDatabase
 {
--- a/src/adplug/core/fprovide.cxx	Wed Dec 06 05:09:57 2006 -0800
+++ b/src/adplug/core/fprovide.cxx	Wed Dec 06 07:37:05 2006 -0800
@@ -52,9 +52,9 @@
 
 /***** CProvider_Filesystem *****/
 
-binistream *CProvider_Filesystem::open(std::string filename) const
+vfsistream *CProvider_Filesystem::open(std::string filename) const
 {
-  binifstream *f = new binifstream(filename);
+  vfsistream *f = new vfsistream(filename);
 
   if(!f) return 0;
   if(f->error()) { delete f; return 0; }
@@ -67,10 +67,9 @@
 
 void CProvider_Filesystem::close(binistream *f) const
 {
-  binifstream *ff = (binifstream *)f;
+  vfsistream *ff = (vfsistream *)f;
 
   if(f) {
-    ff->close();
     delete ff;
   }
 }