//--------------------------------------------------------------------------- // 函数: Load // 功能: 加载一个Tab文件 // 参数: FileName 文件名 // 返回: TRUE 成功 // FALSE 失败 //--------------------------------------------------------------------------- BOOL KTabFile::Load(LPSTR FileName) { KPakFile File; DWORD dwSize; PVOID Buffer; // check file name if (FileName[0] == 0) return FALSE; if (!File.Open(FileName)) { g_DebugLog("Can't open tab file : %s", FileName); return FALSE; } dwSize = File.Size(); Buffer = m_Memory.Alloc(dwSize); File.Read(Buffer, dwSize); CreateTabOffset(); return TRUE; }
//--------------------------------------------------------------------------- // 函数: Load // 功能: 加载一个INI文件 // 参数: FileName 文件名 // 返回: TRUE 成功 // FALSE 失败 //--------------------------------------------------------------------------- BOOL KIniFile::Load(LPCSTR FileName) { KPakFile File; DWORD dwSize; PVOID Buffer; TPackHead* pHeader; // check file name if (FileName[0] == 0) return FALSE; if (m_Header.pNextNode) Clear(); if (!File.Open((char*)FileName)) { g_DebugLog("Can't open ini file : %s", FileName); return FALSE; } #pragma message("KIniFile 当前不支持 KeyName 为中文! by Romandou") dwSize = File.Size(); Buffer = m_MemStack.Push(dwSize + 4); File.Read(Buffer, dwSize); pHeader = (TPackHead*)Buffer; if (pHeader->Id == 0x4b434150) // "PACK" { File.Close(); return LoadPack(FileName); } CreateIniLink(Buffer, dwSize); return TRUE; }
BOOL CChatFilter::Initialize() { Error_SetErrorString("CChatFilter::Initialize()"); if (m_pTextFilter) { return TRUE; } KPakFile FileChatFlt; if (FileChatFlt.Open((char*)file_chatflt) == FALSE) { Error_SetErrorCode(ERR_T_FILE_NO_FOUND); Error_SetErrorString(file_chatflt); return FALSE; } if (SUCCEEDED(g_libFilterText.CreateTextFilter(&m_pTextFilter))) { char* pBuffer = NULL; int nSize = FileChatFlt.Size(); if (nSize) pBuffer = (char*)_alloca(nSize + 1); if (pBuffer) { int nFinalSize = FileChatFlt.Read(pBuffer, nSize); if (nFinalSize >= nSize) pBuffer[nSize] = 0; else memset(pBuffer + nFinalSize, 0, nSize - nFinalSize + 1); char* pLineHeader = pBuffer; do { char* pLineEnd = strchr(pLineHeader, 0x0a); int nLineLen; if (pLineEnd) { *pLineEnd = 0; nLineLen = pLineEnd - pLineHeader; } else { nLineLen = nFinalSize - (pLineHeader - pBuffer); } if (pLineHeader[0] && nLineLen > 0) { if (pLineHeader[nLineLen - 1] == 0x0d) pLineHeader[--nLineLen] = 0; if (nLineLen) { EDOneTimePad_Decipher(pLineHeader, nLineLen); m_pTextFilter->AddExpression(pLineHeader); } } pLineHeader = pLineEnd ? pLineEnd + 1: NULL; }while(pLineHeader); } } FileChatFlt.Close(); if(m_pTextFilter) { return TRUE; } else { Error_SetErrorCode(ERR_T_MODULE_INIT_FAILED); return FALSE; } }