view src/modplug/archive/arch_raw.cxx @ 234:88465b96e4b3 trunk

[svn] - VFS support
author nenolod
date Tue, 07 Nov 2006 01:55:13 -0800
parents 3da1b8942b8b
children 964ad0acc33f
line wrap: on
line source

/* 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 = vfs_fopen(aFileName.c_str(), "rb");

	//open and mmap the file
	if(mFileDesc == NULL)
	{
		mSize = 0;
		return;
	}
	mSize = vfs_ftell(mFileDesc);

	mMap = malloc(mSize);
	vfs_fread(mMap, 0, mSize, mFileDesc);
}

arch_Raw::~arch_Raw()
{
	if(mSize != 0)
	{
		free(mMap);
		vfs_fclose(mFileDesc);
	}
}

bool arch_Raw::ContainsMod(const string& aFileName)
{
	return IsOurFile(aFileName);
}