diff Plugins/Input/modplug/archive/arch_raw.cpp @ 278:37316876ef6e trunk

[svn] Use modplug instead of mikmod. Supports more formats & compressed files.
author chainsaw
date Sat, 10 Dec 2005 14:31:13 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Input/modplug/archive/arch_raw.cpp	Sat Dec 10 14:31:13 2005 -0800
@@ -0,0 +1,55 @@
+/* Modplug XMMS Plugin
+ * Authors: Kenton Varda <temporal@gauge3d.org>
+ *
+ * This source code is public domain.
+ */
+
+//open()
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+//mmap()
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "arch_raw.h"
+
+arch_Raw::arch_Raw(const string& aFileName)
+{
+	mFileDesc = open(aFileName.c_str(), O_RDONLY);
+
+	struct stat lStat;
+
+	//open and mmap the file
+	if(mFileDesc == -1)
+	{
+		mSize = 0;
+		return;
+	}
+	fstat(mFileDesc, &lStat);
+	mSize = lStat.st_size;
+
+	mMap =
+		(uchar*)mmap(0, mSize, PROT_READ,
+		MAP_PRIVATE, mFileDesc, 0);
+	if(!mMap)
+	{
+		close(mFileDesc);
+		mSize = 0;
+		return;
+	}
+}
+
+arch_Raw::~arch_Raw()
+{
+	if(mSize != 0)
+	{
+		munmap(mMap, mSize);
+		close(mFileDesc);
+	}
+}
+
+bool arch_Raw::ContainsMod(const string& aFileName)
+{
+	return IsOurFile(aFileName);
+}