changeset 352:7fc7b66c8a53 trunk

[svn] - you know, it'd help if binio were better documented.
author nenolod
date Sat, 09 Dec 2006 05:52:12 -0800
parents 82a9fabb5b46
children 1bd205b6e83d
files ChangeLog src/adplug/core/binio_virtual.h
diffstat 2 files changed, 55 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Dec 09 05:29:06 2006 -0800
+++ b/ChangeLog	Sat Dec 09 05:52:12 2006 -0800
@@ -1,3 +1,10 @@
+2006-12-09 13:29:06 +0000  Giacomo Lozito <james@develia.org>
+  revision [768]
+  prevent adplug makefile from pointlessly trying to link source files in the core library
+  trunk/src/adplug/core/Makefile |   10 ++++++----
+  1 file changed, 6 insertions(+), 4 deletions(-)
+
+
 2006-12-09 11:37:53 +0000  William Pitcock <nenolod@nenolod.net>
   revision [766]
   - add support for hatena (experimental)
--- a/src/adplug/core/binio_virtual.h	Sat Dec 09 05:29:06 2006 -0800
+++ b/src/adplug/core/binio_virtual.h	Sat Dec 09 05:52:12 2006 -0800
@@ -22,37 +22,54 @@
 	vfsistream() {};
 
 	vfsistream(const char *file) {
-		fd = vfs_fopen(file, "rb");
+		this->fd = vfs_fopen(file, "rb");
 	};
 
 	vfsistream(std::string &file) {
-		fd = vfs_fopen(file.c_str(), "rb");
+		this->fd = vfs_fopen(file.c_str(), "rb");
 	};
 
 	~vfsistream() {
-		if (fd != NULL)
-			vfs_fclose(fd);
+		if (this->fd != NULL)
+			vfs_fclose(this->fd);
 	};
 
 	void open(const char *file) {
-		fd = vfs_fopen(file, "rb");
+		this->fd = vfs_fopen(file, "rb");
 	};
 
 	void open(std::string &file) {
-		fd = vfs_fopen(file.c_str(), "rb");
+		this->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);
+		int c = vfs_getc(this->fd);
+
+		if (c == EOF) err |= Eof;
+
+		return (Byte) c;
 	};
 
 	void seek(long pos, Offset offs = Set) {
-		vfs_fseek(fd, pos, offs == Set ? SEEK_SET : SEEK_CUR);
+		switch (offs)
+		{
+			case Add:
+				vfs_fseek(this->fd, pos, SEEK_CUR);
+				break;
+			case End:
+				vfs_fseek(this->fd, pos, SEEK_END);
+				break;
+			case Set:
+			default:
+				vfs_fseek(this->fd, pos, SEEK_SET);
+				break;
+		}
+
 	}
 
 	long pos(void) {
-		return vfs_ftell(fd);
+		return vfs_ftell(this->fd);
 	}
 };
 
@@ -65,37 +82,50 @@
 	vfsostream() {};
 
 	vfsostream(const char *file) {
-		fd = vfs_fopen(file, "wb");
+		this->fd = vfs_fopen(file, "wb");
 	};
 
 	vfsostream(std::string &file) {
-		fd = vfs_fopen(file.c_str(), "wb");
+		this->fd = vfs_fopen(file.c_str(), "wb");
 	};
 
 	~vfsostream() {
-		if (fd != NULL)
-			vfs_fclose(fd);
+		if (this->fd != NULL)
+			vfs_fclose(this->fd);
 	};
 
 	void open(const char *file) {
-		fd = vfs_fopen(file, "wb");
+		this->fd = vfs_fopen(file, "wb");
 	};
 
 	void open(std::string &file) {
-		fd = vfs_fopen(file.c_str(), "wb");
+		this->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);
+		vfs_fwrite(&b, 1, 1, this->fd);
 	};
 
 	void seek(long pos, Offset offs = Set) {
-		vfs_fseek(fd, pos, offs == Set ? SEEK_SET : SEEK_CUR);
+		switch (offs)
+		{
+			case Add:
+				vfs_fseek(this->fd, pos, SEEK_CUR);
+				break;
+			case End:
+				vfs_fseek(this->fd, pos, SEEK_END);
+				break;
+			case Set:
+			default:
+				vfs_fseek(this->fd, pos, SEEK_SET);
+				break;
+		}
+
 	}
 
 	long pos(void) {
-		return vfs_ftell(fd);
+		return vfs_ftell(this->fd);
 	}
 };