//加载映射表 bool implementsetting::LoadMap(void) { bool result = true; string iopath = GetRunPath(); string impath(iopath.c_str()); string cfgpath(iopath.c_str()); cfgpath = cfgpath.substr(0, cfgpath.rfind('\\')); __runPath.assign(cfgpath); iopath.assign(GetTempFileInfo("~io")); impath.assign(GetTempFileInfo("~implementsetting")); cfgpath.append("\\JcConfig.ini"); __ioPath = iopath; __imPath = impath; __cfgPath = cfgpath; ofstream ofio(iopath); ofstream ofimplt(impath); string fstr; fstr.assign(IO_STRING); ofio.write(fstr.c_str(), fstr.size()); fstr.assign(IMPLEMENT_STRING); ofimplt.write(fstr.c_str(), fstr.size()); ofio.close(); ofimplt.close(); if (LoadParaIM() == false) { result = false; } else { LoadParaIO(); } __logEnable = (0 != atoi(GetRowFromFile("ip","log","0",__cfgPath).c_str())); WindowsDeleteFile(iopath.c_str()); WindowsDeleteFile(impath.c_str()); bLoadMap = result; return result; }
bool S3D_FILENAME_RESOLVER::readPathList( void ) { if( m_ConfigDir.empty() ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = "3D configuration directory is unknown"; ostr << " * " << errmsg.ToUTF8(); wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } wxFileName cfgpath( m_ConfigDir, S3D_RESOLVER_CONFIG ); cfgpath.Normalize(); wxString cfgname = cfgpath.GetFullPath(); size_t nitems = m_Paths.size(); std::ifstream cfgFile; std::string cfgLine; if( !wxFileName::Exists( cfgname ) ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = "no 3D configuration file"; ostr << " * " << errmsg.ToUTF8() << " '"; ostr << cfgname.ToUTF8() << "'"; wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } cfgFile.open( cfgname.ToUTF8() ); if( !cfgFile.is_open() ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; wxString errmsg = "Could not open configuration file"; ostr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'"; wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); return false; } int lineno = 0; S3D_ALIAS al; size_t idx; int vnum = 0; // version number while( cfgFile.good() ) { cfgLine.clear(); std::getline( cfgFile, cfgLine ); ++lineno; if( cfgLine.empty() ) { if( cfgFile.eof() ) break; continue; } if( 1 == lineno && cfgLine.compare( 0, 2, "#V" ) == 0 ) { // extract the version number and parse accordingly if( cfgLine.size() > 2 ) { std::istringstream istr; istr.str( cfgLine.substr( 2 ) ); istr >> vnum; } continue; } idx = 0; if( !getHollerith( cfgLine, idx, al.m_alias ) ) continue; // never add on KISYS3DMOD from a config file if( !al.m_alias.Cmp( wxT( "KISYS3DMOD" ) ) ) continue; if( !getHollerith( cfgLine, idx, al.m_pathvar ) ) continue; if( !getHollerith( cfgLine, idx, al.m_description ) ) continue; addPath( al ); }