void CMainRoot::setUILanguage(const std::string & strLanguage) { std::string strUIFilename = IniGetStr("GameUI.cfg", "UIConfig", "file"); std::string strStringFilename = ChangeExtension(strUIFilename, "String" + strLanguage + ".ini"); // ---- CDlgMain::getInstance().loadString(strStringFilename.c_str()); }
int main(int argc,char **argv) { if(argc!=2) { puts("usage: enc filename"); getch(); return 0; } //======================================== //ファイルからデータの読み込み //======================================== char *pcInFileName = argv[1]; FILE *fp = fopen(pcInFileName,"rb"); fseek(fp,0,SEEK_END); int iSize=ftell(fp); char *pcInBuffer=new char[iSize]; fseek(fp,0,SEEK_SET); fread(pcInBuffer,sizeof(char),iSize,fp); fclose(fp); //==================================== //ファイルへWrite //==================================== char acOutFileName[100]; ChangeExtension(pcInFileName,acOutFileName,"dat"); //出力ファイル名の拡張子入力から変更 char *pcOutBuffer=new char[iSize]; fp = fopen(acOutFileName,"wb"); Encry(pcInBuffer,pcOutBuffer,iSize); //暗号化 fwrite(pcOutBuffer,sizeof(char),iSize,fp); //暗号化したデータをファイルへ書き込み fclose(fp); return 0; }
bool Signal::ReadMitbihFile() { wchar_t HeaFile[_MAX_PATH]; wcscpy(HeaFile, EcgFileName); ChangeExtension(HeaFile, L".hea"); FILE* fh = _wfopen(HeaFile, L"rt"); if (!fh) return false; if (ParseMitbihHeader(fh)) { fclose(fh); pEcgHeader = &EcgHeaders[0]; int lNum = (int)EcgHeaders.size(); int size = pEcgHeader->size; fp = CreateFileW(EcgFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (fp == INVALID_HANDLE_VALUE || (GetFileSize(fp, 0) != (lNum * pEcgHeader->size * pEcgHeader->bits) / 8)) return false; fpmap = CreateFileMapping(fp, 0, PAGE_READONLY, 0, 0, 0); lpMap = MapViewOfFile(fpmap, FILE_MAP_READ, 0, 0, 0); if (lpMap == 0) { CloseFile(); return false; } lps = (short *)lpMap; lpc = (char *)lpMap; for (int i = 0; i < lNum; i++) { pData = new double[pEcgHeader->size]; EcgSignals.push_back(pData); } short tmp; for (int s = 0; s < size; s++) { for (int n = 0; n < lNum; n++) { pData = EcgSignals[n]; pEcgHeader = &EcgHeaders[n]; switch (pEcgHeader->bits) { case 12: //212 format 12bit if ((s*lNum + n) % 2 == 0) { tmp = MAKEWORD(lpc[0], lpc[1] & 0x0f); if (tmp > 0x7ff) tmp |= 0xf000; tmp -= pEcgHeader->bline; pData[s] = (double)tmp / (double)pEcgHeader->umv; } else { tmp = MAKEWORD(lpc[2], (lpc[1] & 0xf0) >> 4); if (tmp > 0x7ff) tmp |= 0xf000; tmp -= pEcgHeader->bline; pData[s] = (double)tmp / (double)pEcgHeader->umv; lpc += 3; } break; case 16: //16format pData[s] = (double)(*lps++ - pEcgHeader->bline) / (double)pEcgHeader->umv; break; } } } CloseFile(); return true; } else {
bool CMyPlug::importTerrainData(iSceneData * pSceneData, const std::string& strFilename) { pSceneData->clear(); if (pSceneData->resize(253,253)) { // EncTerrain IOReadBase* pRead = IOReadBase::autoOpen(strFilename); if (pRead) { if (MAP_FILE_SIZE==pRead->GetSize()) { char buffer[MAP_FILE_SIZE]; pRead->Read(buffer,MAP_FILE_SIZE); decrypt(buffer,MAP_FILE_SIZE); char* p = buffer; unsigned short uMuFlgMap = *((unsigned short*)p); p+=2; for (int y=0; y<253; ++y) { for (int x=0; x<253; ++x) { pSceneData->setCellTileID(x,y,*p,0); p++; } p+=3; } p+=256*3; for (int y=0; y<253; ++y) { for (int x=0; x<253; ++x) { pSceneData->setCellTileID(x,y,*p,1); p++; } p+=3; } p+=256*3; for (int y=0; y<254; ++y) { for (int x=0; x<254; ++x) { pSceneData->setVertexColor(x,y,Color32(*p,255,255,255)); p++; } p+=2; } } IOReadBase::autoClose(pRead); } // EncTerrain.att pRead = IOReadBase::autoOpen(ChangeExtension(strFilename,".att")); if (pRead) { if (ATT_FILE_129KB_SIZE==pRead->GetSize()) { char buffer[ATT_FILE_129KB_SIZE]; pRead->Read(buffer,ATT_FILE_129KB_SIZE); decrypt(buffer,ATT_FILE_129KB_SIZE); decrypt2(buffer,ATT_FILE_129KB_SIZE); char* p = buffer; unsigned long uMuFlgAtt = *((unsigned long*)p); p+=4; for (int y=0; y<253; ++y) { for (int x=0; x<253; ++x) { pSceneData->setCellAttribute(x,y,*p); p+=2; } p+=6; } } else if (ATT_FILE_65KB_SIZE==pRead->GetSize()) { char buffer[ATT_FILE_65KB_SIZE]; pRead->Read(buffer,ATT_FILE_65KB_SIZE); decrypt(buffer,ATT_FILE_65KB_SIZE); decrypt2(buffer,ATT_FILE_65KB_SIZE); char* p = buffer; unsigned long uMuFlgAtt = *((unsigned long*)p); p+=4; for (int y=0; y<253; ++y) { for (int x=0; x<253; ++x) { pSceneData->setCellAttribute(x,y,*p); p++; } p+=3; } } IOReadBase::autoClose(pRead); } // TerrainHeight std::string strHeightFilename = GetParentPath(strFilename)+"TerrainHeight.ozb"; pRead = IOReadBase::autoOpen(strHeightFilename); if (pRead) { if (HEIGHT_HEAD_SIZE+HEIGHT_BUFFER_SIZE<=pRead->GetSize()) { pRead->Move(HEIGHT_HEAD_SIZE); for (int y=0; y<254; ++y) { pRead->Move(2); for (int x=0; x<254; ++x) { unsigned char uVal; pRead->Read(&uVal,1); pSceneData->setVertexHeight(x,y,uVal*0.015f); } } } IOReadBase::autoClose(pRead); } } return true; }
int main(int argc, _TCHAR* argv[]) { mkdir("Dec");mkdir("Enc"); std::wstring wstrFindPath = getCurrentDirectory(); CDir dir; dir.ReadDir(wstrFindPath); for (size_t i=0; i<dir.m_FileInfo.size(); i++) { if (!dir.m_FileInfo[i].IsDirectory()) { std::wstring wstrExt = GetExtension(dir.m_FileInfo[i].wstrFilename); std::string strFilename = ws2s(dir.m_FileInfo[i].wstrFilename); if (wstrExt==L".ozj") { std::string strDestFilename = "Dec\\"+ChangeExtension(strFilename,".jpg"); fileOffset(strFilename,strDestFilename,24); } else if (wstrExt==L".ozt") { std::string strDestFilename = "Dec\\"+ChangeExtension(strFilename,".tga"); fileOffset(strFilename,strDestFilename,4); } else if (wstrExt==L".ozb") { std::string strDestFilename = "Dec\\"+ChangeExtension(strFilename,".bmp"); fileOffset(strFilename,strDestFilename,4); } else if (wstrExt==L".jpg") { std::string strDestFilename = "Enc\\"+ChangeExtension(strFilename,".ozj"); fileOffset(strFilename,strDestFilename,-24); } else if (wstrExt==L".tga") { std::string strDestFilename = "Enc\\"+ChangeExtension(strFilename,".ozt"); fileOffset(strFilename,strDestFilename,-4); } else if (wstrExt==L".bmp") { std::string strDestFilename = "Enc\\"+ChangeExtension(strFilename,".ozb"); fileOffset(strFilename,strDestFilename,-4); } else if (wstrExt==L".map"||wstrExt==L".obj") { decryptMuFile(strFilename,"Dec\\"+strFilename+"d"); } else if (wstrExt==L".att") { decryptMuATTFile(strFilename,"Dec\\"+strFilename+"d"); } else if (wstrExt==L".bmd") { if ("item.bmd"==strFilename) { decryptItemBMD(strFilename,"Dec\\"+ChangeExtension(strFilename,".csv")); } else if ("BuffEffect.bmd"==strFilename) { decryptBuffEffectFile(strFilename,"Dec\\"+strFilename+"d"); } //else if (isEncBmd(strFilename)) //{ // decryptMuFile(strFilename,"Dec\\"+strFilename); //} else { Bmd2Smd(strFilename,"Dec\\"+ChangeExtension(strFilename,".smd")); // decryptMuFileXOR3(strFilename,"Dec\\"+strFilename); } } else if (wstrExt==L".csv") { if ("item.csv"==strFilename) { encryptItemBMD(strFilename,"Enc\\"+ChangeExtension(strFilename,".bmd")); } } else if (wstrExt==L".smd") { Smd2Bmd(strFilename,"Enc\\"+ChangeExtension(strFilename,".bmd")); } } } return 0; }
bool readMaterialTexture(CMaterial& material, IOReadBase* pRead, const std::string& strFilename) { std::string strCommand; std::vector<std::string> setWords; strCommand = getLineCommand(pRead,setWords); if ("{"!=strCommand) { return false; } std::string strTexture; bool bAdd = false; while (!pRead->IsEof()) { strCommand = getLineCommand(pRead,setWords); if ("texture"==strCommand) { if (setWords.size()>0) { strTexture=GetParentPath(strFilename)+setWords[0]; strTexture = ChangeExtension(strTexture,".dds"); } } else if ("colour_op"==strCommand) { if (setWords.size()>0) { if ("add"==setWords[0]) { bAdd = true; } } } else if ("scroll_anim"==strCommand) { if (setWords.size()==2) { material.vTexAnim.x=atof(setWords[0].c_str()); material.vTexAnim.y=atof(setWords[1].c_str()); } } else if ("}"==strCommand) { break; } else { MessageBoxA(NULL,strCommand.c_str(),"Unknon in texture_unit!",0); } } if (strTexture.length()>0) { if (bAdd) { //material.setEmissive(strTexture); material.setTexture(0,strTexture.c_str()); } else { material.setTexture(0,strTexture.c_str()); } } return true; }
bool CMyPlug::importData(iModelData * pModelData, const std::string& strFilename) { assert(pModelData); // Loading the mesh. IOReadBase* pRead = IOReadBase::autoOpen(strFilename); if (!pRead) { return false; } // header readHeader(pRead); // mesh if (!pRead->IsEof()) { unsigned short streamID; unsigned int uLength; pRead->Read(&streamID,sizeof(unsigned short)); pRead->Read(&uLength,sizeof(unsigned int)); switch (streamID) { case M_MESH: { readMesh(pRead,pModelData); break; } } } // close file IOReadBase::autoClose(pRead); // Loading the materials. if (!readMaterial(pModelData,ChangeExtension(strFilename,".material"))) { std::string strMatFilename = GetParentPath(strFilename); strMatFilename=strMatFilename+GetFilename(strMatFilename)+".material"; if (!readMaterial(pModelData,strMatFilename)) { strMatFilename=ChangeExtension(strMatFilename,"_tileset.material"); readMaterial(pModelData,strMatFilename); } } // mesh update pModelData->getMesh().update(); // //m_bbox = mesh.getBBox(); // std::string strMyPath ="Data\\"+GetFilename(GetParentPath(strFilename))+"\\"; // std::string strMatFilename = ChangeExtension(strFilename,".mat.csv"); // std::string strParFilename = ChangeExtension(strFilename,".par.csv"); // if (!IOReadBase::Exists(strMatFilename)) // { // strMatFilename=strMyPath+ChangeExtension(GetFilename(strFilename),".mat.csv"); // } // if (!IOReadBase::Exists(strParFilename)) // { // strParFilename=strMyPath+ChangeExtension(GetFilename(strFilename),".par.csv"); // } // // pModelData->loadMaterial(strMatFilename); // pModelData->loadParticleEmitters(strParFilename); return true; }
void MtcOpcAdapter::initialize(int aArgc, const char *aArgv[]) { static char name[] = "MtcOpcAdapter::initialize"; try{ GLogger << LDEBUG << "MTConnect Adapter Service Configure" << std::endl; _inifile = ChangeExtension(GetModulePath(), ".ini"); // ExeDirectory() + "\\adapter.ini"; if(!ATL::ATLPath::FileExists(_inifile.c_str())) throw std::exception(StdStringFormat("Config file missing %s\n", _inifile.c_str()).c_str()); _iniconfig.load(_inifile); MTConnectService::setName(_iniconfig.GetSymbolValue("Adapter.ServiceName", "MTCAdapter").c_str()); Adapter::mScanDelay = ConvertFromString<int>(_iniconfig.GetSymbolValue("Adapter.ScanDelay", "1000").str(), 1000); this->Adapter::mPort = ConvertFromString<int>(_iniconfig.GetSymbolValue("Adapter.Port", "7878").str(), 7878); std::string sLogLevel = _iniconfig.GetSymbolValue("logger_config.logging_level", "debug"); std::string nLogName = _iniconfig.GetSymbolValue("logger_config.output", "OuputDebugString"); //fatal, error, warn, info, debug GLogger.DebugLevel()= LDEBUG; if(MakeLower(sLogLevel) == "none") GLogger.DebugLevel()= FATAL; else if(MakeLower(sLogLevel) == "error") GLogger.DebugLevel()= ERROR; else if(MakeLower(sLogLevel) == "warn") GLogger.DebugLevel()= WARNING; else if(MakeLower(sLogLevel) == "info") GLogger.DebugLevel()= INFO; else if(MakeLower(sLogLevel) == "fatal") GLogger.DebugLevel()= FATAL; GLogger.Timestamping()= true; if(nLogName=="OuputDebugString") { GLogger.DebugString() = true; } else { GLogger.DebugString() = false; GLogger.Open(::ExeDirectory() + nLogName); } MTConnectService::initialize(aArgc, aArgv); if (aArgc > 1) { mPort = atoi(aArgv[1]); } _bResetAtMidnight = ConvertFromString<bool>(_iniconfig.GetSymbolValue("OPCSERVER.ResetAtMidnight", "false").str(), false); _bOPCEnabled = ConvertFromString<bool>(_iniconfig.GetSymbolValue("OPCSERVER.OPCEnabled", "false").str(), false);; _servers = Tokenize(_iniconfig.GetSymbolValue("OPCSERVER.ServerMachineName", "").str(), ","); _devices = Tokenize(_iniconfig.GetSymbolValue("OPCSERVER.MTConnectDevice", "").str(), ","); _tags = Tokenize(_iniconfig.GetSymbolValue("OPCSERVER.OpcTags", "").str(), ","); if(_servers.size() != _devices.size() && _servers.size() != _tags.size()) throw std::exception("OPC Number of Server IPs does not match number of MTConnect devices or Section Tags" ); } catch(std::exception e) { GLogger << FATAL << "Adapter::initialize() failed: " << e.what() << std::endl; throw e; } catch(...) {} }