⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file.cpp

📁 一个3D的保龄球的源代码
💻 CPP
字号:
// File.cpp: implementation of the HG_File class.
//
//////////////////////////////////////////////////////////////////////
#pragma warning(disable:4786)

//#include "Defines.h"
#include "File.h"

#include "AEEUnzipStream.h"
#include "AEEStdLib.h"
#include "AEEFile.h"
#include "AEEShell.h"
#include "ResFile.h"
//#include "MemFunc.h"

#define COMPRESSED_HEADER_SIZE	4
#ifndef AEE_SIMULATOR
#define LZMA_BASE_SIZE 1846
#define LZMA_LIT_SIZE 768
#else
//#include "LzmaDecode.h"
#endif
HG_File::HG_File()
{
	

}

HG_File::~HG_File()
{
	Close();
}

//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------

bool HG_File::Open(const char* in_pFilePath, int in_nFlags,CEngine *pGame)
{
	//DBGPRINTF("----Loading File:%s----",in_pFilePath);
	char fn[256];
	SPRINTF(fn,"res\\%s",in_pFilePath);
	
	if((int)in_pFilePath == 0x0012f7fc)
		in_pFilePath = in_pFilePath;
	void *h = pGame->GetRes()->FindRecord(fn);
	if (h == NULL )
	{
		return false;
	}
	m_iFileLen = pGame->GetRes()->GetDecompressedSize(h);
	m_pOutStream = MALLOC(m_iFileLen);
	if(m_pOutStream)
	{
		pGame->GetRes()->Read(h,m_pOutStream,m_iFileLen);
		m_pBR = new CBufReader(m_pOutStream,m_iFileLen);	
		if(m_pBR)
			return true;
	
	}

	return false;

	
}

//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------

void HG_File::Close()
{
	if(m_pBR)
		delete m_pBR;
	if(m_pOutStream)
		delete m_pOutStream;
	//SAFE_DELETE(m_pBR);
//	SAFE_DELETE(m_pOutStream);
	
}
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
unsigned int HG_File::Read(void * out_pData, unsigned int in_nSize)
{
#ifdef LZMA
	m_pBR->ReadBlock(out_pData,in_nSize);
#else
	return IFILE_Read(m_pFile,out_pData,in_nSize);
#endif
	
	return 1;
}

unsigned int HG_File::Write(const void * in_pData, unsigned int in_nSize)
{
	//return IFILE_Write(m_pFile,in_pData,in_nSize);
	return 0;
}

char HG_File::GetChar()
{
	char data;
	Read(&data, 1);
	return data;
}

bool HG_File::Seek(unsigned int nOffsetFromStart)
{
	#ifdef LZMA
		m_pBR->Seek(nOffsetFromStart);
		return true;
	#else
		return IFILE_Seek(m_pFile,_SEEK_START,nOffsetFromStart);
	#endif	
}



int HG_File::GetFileLen()
{
	return m_iFileLen;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -