BOOL fsLangMgr::Initialize() { LoadBuiltInLngStrings (); WIN32_FIND_DATA wfd; m_strLngFolder = ((CFdmApp*)AfxGetApp ())->m_strAppPath; m_strLngFolder += "Language\\"; CString strMask = m_strLngFolder; strMask += "*.lng"; HANDLE hFind = FindFirstFile (strMask, &wfd); BOOL bFind = hFind != INVALID_HANDLE_VALUE; while (bFind) { try { fsLngFileInfo info; info.strFileName = wfd.cFileName; info.strFileNameWoExt = wfd.cFileName; ASSERT (info.strFileNameWoExt.GetLength () > 4); info.strFileNameWoExt.Delete (info.strFileNameWoExt.GetLength ()-4, 4); CStdioFile file (m_strLngFolder + info.strFileName, CFile::modeRead | CFile::typeText | CFile::shareDenyNone); while (file.ReadString (info.strLngName)) { if (info.strLngName.GetLength () && info.strLngName [0] != LNG_COMMENT_CHAR) { AddLngFileInfo (info); break; } } } catch (const std::exception& ex) { ASSERT (FALSE); vmsLogger::WriteLog("fsLangMgr::Initialize " + tstring(ex.what())); } catch (...) { ASSERT (FALSE); vmsLogger::WriteLog("fsLangMgr::Initialize unknown exception"); } bFind = FindNextFile (hFind, &wfd); } if (hFind != INVALID_HANDLE_VALUE) FindClose (hFind); return m_vLngFiles.size () != 0; }
BOOL fsLangMgr::Initialize(LPCSTR pszFolder) { m_strFolder = pszFolder; WIN32_FIND_DATA wfd; std::string strMask = m_strFolder; strMask += "\\*.lng"; HANDLE hFind = FindFirstFile (strMask.c_str (), &wfd); BOOL bFind = hFind != INVALID_HANDLE_VALUE; while (bFind) { fsLngFileInfo info; info.strFileName = m_strFolder; info.strFileName += "\\"; info.strFileName += wfd.cFileName; vmsFile file; if (file.open (info.strFileName.c_str ())) { while (file.read (info.strLngName)) { if (info.strLngName.length () && info.strLngName [0] != LNG_COMMENT_CHAR) { AddLngFileInfo (info); break; } } } bFind = FindNextFile (hFind, &wfd); } if (hFind != INVALID_HANDLE_VALUE) FindClose (hFind); LoadEngFileStrings (); return m_vLngFiles.size () != 0; }