/*
	BinMaker program
	Copyright 2007 Jonathan Wilson
	Portions lifted from BinOpener copyright 2007 booto (temptemp91 at hotmail dot com)

	This file is part of binmaker.

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	binmaker is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
#include <stdio.h>
#include "manifestitem.h"
#include "aptgeometrydata.h"

AptGeometryData::AptGeometryData(const char *streamname,const char *sourcename,const char *file,unsigned int hash2, unsigned int hash4, unsigned int GeometryNumber)
{
	StreamName = _strdup(streamname);
	SourceName = _strdup(sourcename);
	Header.filenamehash1 = 0x3daa8c20;
	Header.filenamehash2 = hash2;
	Header.filenamehash3 = 0x58f89e8b;
	Header.filenamehash4 = hash4;
	FILE *f = fopen(file,"rb");
	fseek(f,0,SEEK_END);
	int filesize = ftell(f);
	fseek(f,0,SEEK_SET);
	StreamSize = filesize + 16;
	StreamData = new char[StreamSize];
	memset(StreamData,0,StreamSize);
	((unsigned int *)StreamData)[0] = 0;
	((unsigned int *)StreamData)[1] = 0x10;
	((unsigned int *)StreamData)[2] = filesize;
	((unsigned int *)StreamData)[3] = GeometryNumber;
	fread(&StreamData[16],filesize,1,f);
	RelocationEntries.push_back(0x4);
	fclose(f);
}
