예제 #1
0
파일: DBC.cpp 프로젝트: joyfish/tianxiadiyi
	BOOL DBCFile::OpenFromTXT(const CHAR* szFileName)
	{
		assert(szFileName);
		m_szFileName = szFileName;

		//----------------------------------------------------
		//打开文件
		FILE* fp = fopen(szFileName, "rb");
		if(NULL == fp) 
			return FALSE;

		fseek(fp, 0, SEEK_END);
		int nFileSize = ftell(fp);
		fseek(fp, 0, SEEK_SET);

		//读入内存
		char* pMemory = new char[nFileSize+1];
		memset(pMemory,0,nFileSize+1);
		fread(pMemory, 1, nFileSize, fp);
		pMemory[nFileSize] = 0;

		const char* pDeadEnd = &pMemory[nFileSize];
		BOOL bRet = OpenFromMemory(pMemory,pDeadEnd,szFileName);

		SAFE_DELETE_ARRAY(pMemory); pMemory = 0;
		return bRet;
	}
예제 #2
0
BOOL DBCFile::OpenFromTXT(const CHAR* szFileName)
{
	assert(szFileName);

	//----------------------------------------------------
	//打开文件
	FILE* fp = fopen(szFileName, "rb");
	if(NULL == fp) return FALSE;

	fseek(fp, 0, SEEK_END);
	int nFileSize = ftell(fp);
	fseek(fp, 0, SEEK_SET);

	//读入内存
	char* pMemory = new char[nFileSize+1];
	fread(pMemory, 1, nFileSize, fp);
	pMemory[nFileSize] = 0;

	BOOL bRet = OpenFromMemory(pMemory, pMemory+nFileSize+1, szFileName);

	delete[] pMemory; pMemory = 0;
	return bRet;
}