NrpText OpFileSystem::CheckFile( const NrpText& dir, const NrpText& fileName ) { assert( IsExist( dir ) ); if( !fileName.size() ) return L""; if( IsExist( fileName ) ) return fileName; NrpText finalName = CheckEndSlash( dir ) + fileName; if( IsExist( finalName ) ) return finalName; return fileName; }
bool GameLogic::SearchPath2(CGraph &graph, int nV0, int nV1) { //得到顶点数 int nVexnum = graph.GetVexnum(); //遍历图中nV0行,从0列到nVexnum列,值为true的点 for (int nVi = 0; nVi < nVexnum; nVi++) { if (graph.GetArc(nV0, nVi) && !IsExist(nVi)) { //压入当前顶点。假设为路径的一个有效顶点 PushVertex(nVi); if (m_nCorner > 2) { PopVertex(); continue; } if (nVi != nV1) { //当中间顶点为空时,表示该条路径不通 if (graph.GetVertex(nVi) != BLANK) { PopVertex(); continue; } //如果nVi是一个已消除的点,则判断(nVi,nV1)是否连通 if (SearchPath2(graph, nVi, nV1)) { return true; } } else { return true; } PopVertex(); } } return false; }
BOOL ringDir::BeginFindFile(LPCTSTR szFilename,LPTSTR lpBuf) { FindClose(); memset(m_szCurrDir,0,MAX_PATH*sizeof(TCHAR)); GetCurrentDirectory(MAX_PATH,m_szCurrDir); TCHAR szTmp[MAX_PATH]; if(m_szDir[lstrlen(m_szDir)-1] != '\\') wsprintf(szTmp,"%s\\\0",m_szDir); else wsprintf(szTmp,"%s\0",m_szDir); if(IsExist()) { SetCurrentDirectory(szTmp); if(szFilename == NULL) szFilename = "*.*"; //wsprintf(szTmp,"%s\\%s\0",m_szDir,szFilename); m_handle = FindFirstFile(szFilename,&m_data); if(m_handle == INVALID_HANDLE_VALUE) { m_handle = NULL; SetCurrentDirectory(m_szCurrDir); return FALSE; } else if(lpBuf) wsprintf(lpBuf,"%s\0",m_data.cFileName); return TRUE; } return FALSE; }
bool MeshManager::Add(const std::string &name, Mesh *mesh) { if(IsExist(name)) { return false; } mesh_dict_[name] = mesh; return true; }
NrpText OpFileSystem::UpDir( const NrpText& pathTo ) { assert( IsExist( pathTo ) ); if( !pathTo.size() ) return L""; NrpText pathToAny = RemoveEndSlash( pathTo ); int index = pathToAny.findLast( L'\\' ); if( index < 0 ) index = pathToAny.findLast( L'/' ); if( index >=0 ) return pathToAny.subString( 0, index+1 ); assert( IsExist( pathTo ) ); return L""; }
int CCliReq::IsExist(const char *a_szArgName) { std::string strArgName; strArgName = a_szArgName; return IsExist(strArgName); }
// Inserts new value to the statistics void GaStatistics::AddValue(int id, GaValueHistoryBase* value) { GA_ARG_ASSERT( Common::Exceptions::GaNullArgumentException, value != NULL, "value", "Value object must be specified.", "Statistics" ); GA_ARG_ASSERT( Common::Exceptions::GaArgumentException, !IsExist( id ), "id", "A value with specified value is already registered.", "Statistics" ); _values[ id ] = value; }
void CGroupPackFileDownloadWnd::OnDownLoadPackFiles() { if (NULL != m_pGroupPackFileList && NULL != m_pCurrPackItem) { //if (!m_bDownloaded) //{ int nFileCount = m_pCurrPackItem->listFile.size(); for (list<sPackFileItem>::iterator it = m_pCurrPackItem->listFile.begin(); it != m_pCurrPackItem->listFile.end(); ++it) { tstring strAliUrl = it->strFileUrl; tstring strFileName = it->strFileName; DWORD dwFileSize = _tcstoul(it->strFileSizeAccurate.c_str(), NULL, 10); fileInfo* pOneFile = new fileInfo; pOneFile->strFileUrl = strAliUrl; pOneFile->strFileName = strFileName; pOneFile->strFilePath = CFileHelper::GetPackDir(it->strPackName, it->strPackID); pOneFile->strFilePath += strFileName;//用户目录下的临时文件夹。 pOneFile->dwFileSize = dwFileSize; //先判断有没有这个文件了,如有就直接更新状态为 ”打开“可用 bool bExist = PathFileExists(pOneFile->strFilePath.c_str()); if (bExist) { if (getFileSize(pOneFile->strFilePath) == dwFileSize) { if (!IsExist(pOneFile->strFilePath)) { ::EnterCriticalSection(&m_csFState); m_mapFile2State.insert(make_pair(pOneFile->strFilePath, enm_DownState_Finish)); ::LeaveCriticalSection(&m_csFState); //设置进度条为完成了。//说来话长,这个98就表示下载完成了... m_pGroupPackFileList->SetProgress(pOneFile->strFileFullName, 98); } delete pOneFile; } } else { //正在下载的文件项目 ::EnterCriticalSection(&m_csFState); m_mapFile2State.insert(make_pair(pOneFile->strFilePath, enm_DownState_OnGoing)); ::LeaveCriticalSection(&m_csFState); downloadFiles(*pOneFile, this); } } //} } }
bool StageRealizer::Load(Stage** ppStage, MoveSequence** ppSeq, const TCHAR* basepath, const TCHAR* subdir, const MotionGuideList& mgl) { if (ppStage == NULL) { return false; } if (basepath == NULL || basepath[0] == _T('\0')) { return false; } if (subdir == NULL || subdir[0] == _T('\0')) { return false; } if (! IsExist(basepath, subdir)) { return false; } MotionGuidePair mg; if (! MoveRealizer::IsExist(&mg, basepath, subdir, mgl)) { return false; } Stage* pStage = NULL; MoveSequence* pSeq = NULL; { int fd; std::basic_string< TCHAR > path = GetFilePath(basepath, subdir); errno_t err = _tsopen_s(&fd, path.c_str(), _O_RDONLY|_O_BINARY, _SH_DENYWR, _S_IREAD|_S_IWRITE); if (err != 0) { return false; } ::pb::Stage idea; google::protobuf::io::FileInputStream in(fd); bool parsed = google::protobuf::TextFormat::Parse(&in, &idea); _close(fd); if (!parsed) { return false; } std::basic_string< TCHAR > dirpath = GetDirPath(basepath, subdir); if (! StageRealizer::Realize(&pStage, idea, subdir, dirpath.c_str())) { return false; } } if (ppSeq) { if (! MoveRealizer::Load(&pSeq, basepath, subdir, mg)) { goto fail; } } *ppStage = pStage; if (ppSeq) { *ppSeq = pSeq; } return true; fail: if (pStage) { delete pStage; } if (pSeq) { delete pSeq; } if (ppStage) { *ppStage = NULL; } if (ppSeq) { *ppSeq = NULL; } return true; }
void OpFileSystem::Remove( const NrpText& pathTo ) { if( !IsFolder( pathTo ) ) //файл можно удалить сразу DeleteFileW( pathTo.ToWide() ); else { NrpText mStr = CheckEndSlash( pathTo ); _wfinddata_t fdata; intptr_t hFile; assert( IsExist( mStr ) ); if( IsExist( mStr ) ) { hFile = _wfindfirst( ( mStr + anyFile ).ToWide(), &fdata); while( hFile > 0 ) { if ( !( firstEntry == fdata.name || secondEntry == fdata.name ) )// это удалять не надо if ((( fdata.attrib & _A_SUBDIR ) == _A_SUBDIR ) || ( fdata.attrib == _A_SUBDIR ))// найдена папка { Remove( CheckEndSlash( mStr ) + NrpText( fdata.name ) ); } else// иначе найден файл { DeleteFileW( ( CheckEndSlash( mStr ) + fdata.name ).ToWide() ); } if( _wfindnext( hFile, &fdata) != 0 ) break; } _findclose( hFile ); } if( !RemoveDirectoryW( RemoveEndSlash( mStr ).ToWide() ) ) { int rr = GetLastError(); rr = rr; } } }
bool TextureManager::Add(const Texture &tex) { const string &name = tex.name(); if(IsExist(name) == true) { //already exist return false; } TexturePtr cpy_tex(new Texture(tex)); cpy_tex->Init(); tex_dict_[name] = cpy_tex; return true; }
// 创建一个定时器. int Timer::CreateTimer(int MSec) { // 首先, 要找到一个空的id. OneTimer timer; timer.id = rand(); if( IsExist( timer.id )) CreateTimer( MSec ); // 如果已经存在了,则递归. timer.time = GetTickCount(); m_timer.push_back( timer ); return timer.id; }
void OpFileSystem::Copy( const NrpText& pathOld, const NrpText& pathNew ) { NrpText newfile; intptr_t hFile; if( !IsExist( pathNew ) ) CreateDirectory( pathNew ); _wfinddata_t fdata; assert( IsExist( pathOld ) ); if( IsExist( pathOld ) ) { hFile = _wfindfirst( ( CheckEndSlash( pathOld )+ anyFile ).ToWide(), &fdata); while( hFile > 0 ) { if ( fdata.attrib & _A_SUBDIR ) // если нашли папку { if( !( firstEntry == fdata.name || secondEntry == fdata.name ) ) { Copy( CheckEndSlash( pathOld ) + NrpText( fdata.name ), CheckEndSlash( pathNew ) + NrpText( fdata.name ) );// Рекурсивный вызов } } else // если нашли файл { newfile = CheckEndSlash( pathNew ) + fdata.name; CopyFileW( ( CheckEndSlash( pathOld ) + fdata.name ).ToWide(), newfile.ToWide(), true); } if( _wfindnext( hFile, &fdata) != 0 ) break; } _findclose( hFile ); } return; }
BOOL CRegisterExport::IsSubKey(HKEY hKey,LPCTSTR lpSubKey) { if(IsExist(hKey,lpSubKey)) { HKEY phkResult; if( ERROR_SUCCESS == RegOpenKeyEx(hKey,lpSubKey,0, KEY_READ,&phkResult)) { TCHAR sz[MAX_PATH]; if( ERROR_SUCCESS == RegEnumKey(phkResult, 0, sz, MAX_PATH)) { RegCloseKey(phkResult); return TRUE; } RegCloseKey(phkResult); } } return FALSE; }
void OpFileSystem::CreateDirectory( NrpText pathTo ) { if( IsExist( pathTo ) ) return; for( int i=0; i < 5; i++ ) { BOOL created = CreateDirectoryW( RemoveEndSlash( pathTo ).ToWide(), NULL ); assert( created ); if( !created ) { Log( HW ) << "Can't create directory " << pathTo << term; Sleep( 500 ); } else return; } }
bool OpFileSystem::IsFolder( const NrpText& pathTo ) { bool ret = false; NrpText myPath = RemoveEndSlash( pathTo ); if( !IsExist( myPath ) ) Log( HW ) << "Try delete unexisting file " << myPath << term; _wfinddata_t fdata; intptr_t hFile; hFile = _wfindfirst( myPath, &fdata); if( hFile != -1 ) { ret = ((( fdata.attrib & _A_SUBDIR ) == _A_SUBDIR ) || ( fdata.attrib == _A_SUBDIR ));// это папка } _findclose( hFile ); return ret; }
void CHorseRaceMainDlg::RefreshQData() { int nSize; for (int i = 0; i < 2 ; ++i) { std::list<QDATA> * list_data = m_HttpHandule.GetQData(i+1); CString tem; if(list_data) { if(!m_bInit) { nSize = list_data->size(); for (int j = 0; j< nSize;++j) { tem.Format(_T("%d"),list_data->front().race); m_ListQ[i].InsertItem(j,tem); tem.Format(_T("%d-%d"),list_data->front().horse1,list_data->front().horse2); m_ListQ[i].SetItemText(j,1,tem); tem.Format(_T("%d"),list_data->front().ticket); m_ListQ[i].SetItemText(j,2,tem); tem.Format(_T("%d"),list_data->front().amount); m_ListQ[i].SetItemText(j,3,tem); tem.Format(_T("%d"),list_data->front().limit); m_ListQ[i].SetItemText(j,4,tem); list_data->pop_front(); } }else { nSize = m_ListQ[i].GetItemCount(); //m_ListQ1.DeleteAllItems() for (int j = 0; j< nSize;++j) { if(!IsExist(i,j,list_data))//不在新的数据中, { m_ListQ[i].DeleteItem(j); --j; --nSize; } else//存在新的数据,那么就修改 { tem.Format(_T("%d"),list_data->front().race); m_ListQ[i].SetItemText(j,0,tem); tem.Format(_T("%d-%d"),list_data->front().horse1,list_data->front().horse2); m_ListQ[i].SetItemText(j,1,tem); tem.Format(_T("%d"),list_data->front().ticket); m_ListQ[i].SetItemText(j,2,tem); tem.Format(_T("%d"),list_data->front().amount); m_ListQ[i].SetItemText(j,3,tem); tem.Format(_T("%d"),list_data->front().limit); m_ListQ[i].SetItemText(j,4,tem); list_data->pop_front(); } } nSize = list_data->size(); for (int j = 0; j< nSize;++j) { int nTem = m_ListQ[i].GetItemCount(); tem.Format(_T("%d"),list_data->front().race); m_ListQ[i].InsertItem(nTem,tem); tem.Format(_T("%d-%d"),list_data->front().horse1,list_data->front().horse2); m_ListQ[i].SetItemText(nTem,1,tem); tem.Format(_T("%d"),list_data->front().ticket); m_ListQ[i].SetItemText(nTem,2,tem); tem.Format(_T("%d"),list_data->front().amount); m_ListQ[i].SetItemText(nTem,3,tem); tem.Format(_T("%d"),list_data->front().limit); m_ListQ[i].SetItemText(nTem,4,tem); list_data->pop_front(); } } } } m_bInit = true; }
BOOL CAirportsManager::ReadCommonAirports(const CString& _path) { CFile* pFile = NULL; CString sFileName = _path + "\\" + _strAirportFileName; BOOL bRet = TRUE; // airport file try { pFile = new CFile(sFileName, CFile::modeRead | CFile::shareDenyNone); CArchive ar(pFile, CArchive::load); char line[1024]; //skip a line CString csLine; ar.ReadString( csLine ); //read line 2 ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); if(_stricmp(line, "AIRPORTS DATABASE") == 0) { //skip the column names ar.ReadString( csLine ); //read the values //read a line ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); while( *line != '\0' ) { CAirport* pAP = new CAirport(); char* b = line; char* p = NULL; int c = 1; while((p = strchr(b, ',')) != NULL) { *p = '\0'; switch(c) { case 1: //IATA code pAP->m_sIATACode = b; break; case 2: //Desc pAP->m_sLongName = b; break; case 3: // ICAO code... pAP->m_sICAOCode = b; break; case 4: // ARP coordinates... pAP->m_sARPCoordinates = b; break; case 5: // City... pAP->m_sCity = b; break; case 6: // Country... pAP->m_sCountry = b; break; case 7: // Country code... pAP->m_sCountryCode = b; break; case 8: // Elevation... pAP->m_sElevation = b; break; case 9: // Number of runways... pAP->m_sNumberOfRunways = b; break; case 10: // Maximum runway length... pAP->m_sMaximumRunwayLength = b; break; case 11: // Alternate airport ICAO code... pAP->m_sAlternateAirportICAOCode = b; break; default: CString tmp = b; break; } b = ++p; c++; } if(b!= NULL) { pAP->m_sAlternateAirportICAOCode = b; } if(!IsExist(pAP)) m_vAirports.push_back(pAP); else delete pAP ; ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); } } else { bRet = FALSE; } ar.Close(); delete pFile; } catch(CException* e) { AfxMessageBox("Error reading Airports file: " + sFileName, MB_ICONEXCLAMATION | MB_OK); e->Delete(); if(pFile != NULL) delete pFile; bRet = FALSE; } return bRet ; }
BOOL CAirportsManager::LoadData( const CString& _strDBPath ) { Clear(); m_strDBPath = _strDBPath; // ReadCommonAirports(m_strCommonDBPath) ; CFile* pFile = NULL; CString sFileName = _strDBPath + "\\" + _strAirportFileName; BOOL bRet = TRUE; // airport file try { pFile = new CFile(sFileName, CFile::modeRead | CFile::shareDenyNone); CArchive ar(pFile, CArchive::load); char line[1024]; //skip a line CString csLine; ar.ReadString( csLine ); //read line 2 ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); if(_stricmp(line, "AIRPORTS DATABASE") == 0) { //skip the column names ar.ReadString( csLine ); //read the values //read a line ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); while( *line != '\0' ) { CAirport* pAP = new CAirport(); char* b = line; char* p = NULL; int c = 1; while((p = strchr(b, ',')) != NULL) { *p = '\0'; switch(c) { case 1: //IATA code pAP->m_sIATACode = b; break; case 2: //Desc pAP->m_sLongName = b; break; case 3: // ICAO code... pAP->m_sICAOCode = b; break; case 4: // ARP coordinates... pAP->m_sARPCoordinates = b; break; case 5: // City... pAP->m_sCity = b; break; case 6: // Country... pAP->m_sCountry = b; break; case 7: // Country code... pAP->m_sCountryCode = b; break; case 8: // Elevation... pAP->m_sElevation = b; break; case 9: // Number of runways... pAP->m_sNumberOfRunways = b; break; case 10: // Maximum runway length... pAP->m_sMaximumRunwayLength = b; break; case 11: // Alternate airport ICAO code... pAP->m_sAlternateAirportICAOCode = b; break; default: CString tmp = b; break; } b = ++p; c++; } if(b!= NULL) { pAP->m_sAlternateAirportICAOCode = b; } if(!IsExist(pAP)) m_vAirports.push_back(pAP); else delete pAP ; ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); } } else { bRet = FALSE; } ar.Close(); delete pFile; } catch(CException* e) { AfxMessageBox("Error reading Airports file: " + sFileName, MB_ICONEXCLAMATION | MB_OK); e->Delete(); if(pFile != NULL) delete pFile; bRet = FALSE; } // sector file pFile = NULL; sFileName = _strDBPath + "\\" + _strSectorFileName; try { pFile = new CFile(sFileName, CFile::modeRead | CFile::shareDenyNone); CArchive ar(pFile, CArchive::load); char line[2048]; CString csLine; ar.ReadString( csLine ); //read line 2 ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); if(_stricmp(line, "SECTORS DATABASE") == 0) { //skip the column names ar.ReadString( csLine ); //read the values //read a line ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); while( *line != '\0') { //CSector* pS = new CSector(); CString sSectorName; CString sAirport; char* b = line; char* p = NULL; int c = 1; while((p = strchr(b, ',')) != NULL) { *p = '\0'; switch(c) { case 1: //name sSectorName = b; break; case 2: //airport(s) sAirport = b; break; default: //more airports CString tmp = b; sAirport = sAirport + "," + tmp; break; } b = ++p; c++; } if(b!=NULL) // the last column did not have a comma after it { switch(c) { case 1: //name sSectorName = b; break; case 2: //airport(s) sAirport = b; break; default: //more airports CString tmp = b; sAirport = sAirport + "," + tmp; break; } } CAIRPORTFILTER apFilter; while(TRUE) { int nIdx = sAirport.Find(','); if(nIdx != -1) { // found a comma apFilter.sIATACode = sAirport.Left(nIdx); AddSector(sSectorName, apFilter); sAirport = sAirport.Right(sAirport.GetLength()-nIdx-1); } else if(!sAirport.IsEmpty()){ // no comma, but string not empty apFilter.sIATACode = sAirport; AddSector(sSectorName, apFilter); break; } else { // no comma, string empty break; } } ar.ReadString( csLine ); csLine.MakeUpper(); strcpy( line, csLine ); } } else bRet = FALSE; ar.Close(); delete pFile; } catch(CException* e) { AfxMessageBox("Error reading Sectors file: " + sFileName, MB_ICONEXCLAMATION | MB_OK); e->Delete(); if(pFile != NULL) delete pFile; bRet = FALSE; } return bRet; }
bool CParseChannelSettingConfig::ReadChannelSettingConfigFile() { // read file QDomDocument doc; QString strFileName = CHANNEL_SETTING_CONFIG_FILE; if( !ReadFile( doc, strFileName ) ) return false; // root 节点 (configs) QDomElement rootElem = doc.documentElement(); if( ROOT_NODE != rootElem.nodeName() ) { qWarning() << qPrintable( strFileName ) << "format is error, Please checkout your xml file!"; return false; } // channel 节点 QDomNodeList channelList = rootElem.childNodes(); //获得channel列表 int nCount = channelList.count(); for( int i = 0; i < nCount; ++i ) { QDomElement channelElem = channelList.at(i).toElement(); if( !channelElem.isElement() \ || 0 != QString::compare( channelElem.nodeName(), CHANNEL_NODE, Qt::CaseInsensitive ) ) { continue; } QDomNodeList channelChildList = channelElem.childNodes(); //获得channel子列表 CHANNEL_SETTING_INFO channelSettingInfo; int nChildCount = channelChildList.count(); for( int j = 0; j < nChildCount; ++j ) { QDomElement channelSettingChildElem = channelChildList.at(j).toElement(); if( !channelSettingChildElem.isElement() ) continue; QString strNodeName = channelSettingChildElem.nodeName(); QString strText = channelSettingChildElem.text(); int nValue = strText.toInt(); if( 0 == QString::compare( strNodeName, NUM_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.nChannelNum = nValue; else if( 0 == QString::compare( strNodeName, QUALITY_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.enuQuality =(QUALITY_ID)nValue; else if( 0 == QString::compare( strNodeName, RTMP_ENABLE_NODE1, Qt::CaseInsensitive ) ) channelSettingInfo.bRtmpEnable1 = ( 1 == nValue ); else if( 0 == QString::compare( strNodeName, RTMP_ADDR_NODE1, Qt::CaseInsensitive ) ) channelSettingInfo.strRtmpAddr1 = strText; else if( 0 == QString::compare( strNodeName, RTMP_AUDIO_DELAY_NODE1, Qt::CaseInsensitive ) ) channelSettingInfo. nRtmpAudioDelay1= nValue; else if( 0 == QString::compare( strNodeName, RTMP_ENABLE_NODE2, Qt::CaseInsensitive ) ) channelSettingInfo.bRtmpEnable2 = ( 1 == nValue ); else if( 0 == QString::compare( strNodeName, RTMP_ADDR_NODE2, Qt::CaseInsensitive ) ) channelSettingInfo.strRtmpAddr2 = strText; else if( 0 == QString::compare( strNodeName, RTMP_AUDIO_DELAY_NODE2, Qt::CaseInsensitive ) ) channelSettingInfo. nRtmpAudioDelay2= nValue; else if( 0 == QString::compare( strNodeName, UDP_RTP_ENABLE_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.bUdpOrRtpEnable = ( 1 == nValue ); else if( 0 == QString::compare( strNodeName, UDP_RTP_ADDR_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.bUdpOrRtpAddr = ( 1 == nValue ); else if( 0 == QString::compare( strNodeName, UDP_RTP_IP_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.strUdpOrRtpIp = strText; else if( 0 == QString::compare( strNodeName, UDP_RTP_PORT_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.nUdpOrRtpPort = nValue; else if( 0 == QString::compare( strNodeName, UDP_RTP_AUDIO_DELAY_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.nUdpOrRtpAudioDelay = nValue; else if( 0 == QString::compare( strNodeName, INPUT_VIDEO_FORMAT_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.nInputVideoFormat = nValue; else if( 0 == QString::compare( strNodeName, OUTPUT_VIDEO_FORMAT_NODE, Qt::CaseInsensitive ) ) channelSettingInfo.nOutputVideoFormat = nValue; } // save to vector if( !IsExist( channelSettingInfo ) ) { m_vecChannelSettingInfo.append( channelSettingInfo ); m_vecNewChannelSettingInfo.append( channelSettingInfo ); } } return true; }
// select color of cell with the greatest count of cells adjacent to blasted region char CBoard::getCharByAlgorithm(string algorithm) { vector<char> existChars; if (algorithm == "greedy1adjacent") { int iMax = 0; for (int i = 0; i < _colorCount; i++) { int iCount = getCountByGreedy1Adjacent(ColorChars[i]); // exchange if new cell has larger count than max count if (iMax < iCount) { existChars.clear(); // store color with the greatest count of cell existChars.push_back(ColorChars[i]); iMax = iCount; } else if (iMax == iCount) existChars.push_back(ColorChars[i]); } } else if (algorithm == "greedy1all") { int iMax = 0; for (int i = 0; i < _colorCount; i++) { int iCount = getCountByGreedy1All(ColorChars[i]); // exchange if new cell has larger count than max count if (iMax < iCount) { existChars.clear(); // store color with the greatest count of cell existChars.push_back(ColorChars[i]); iMax = iCount; } else if (iMax == iCount) existChars.push_back(ColorChars[i]); } } else if (algorithm == "greedy2adjacent") { int iMax = 0; for (int i = 0; i < _colorCount; i++) { for (int j = 0; j < _colorCount; j++) { int iCount = getCountByGreedy2All(ColorChars[i], ColorChars[j]); // exchange if new cell has larger count than max count if (iMax < iCount) { existChars.clear(); // store color with the greatest count of cell existChars.push_back(ColorChars[i]); iMax = iCount; } else if (iMax == iCount) existChars.push_back(ColorChars[i]); } } } else if (algorithm == "greedy2all") { int iMax = 0; for (int i = 0; i < _colorCount; i++) { for (int j = 0; j < _colorCount; j++) { int iCount = getCountByGreedy2All(ColorChars[i], ColorChars[j]); // exchange if new cell has larger count than max count if (iMax < iCount) { existChars.clear(); // store color with the greatest count of cell existChars.push_back(ColorChars[i]); iMax = iCount; } else if (iMax == iCount) existChars.push_back(ColorChars[i]); } } } else if (algorithm == "random") { for (int i = 0; i < _colorCount; i++) { if (IsExist(ColorChars[i])) { // store color if is adjacent to blasted region existChars.push_back(ColorChars[i]); } } } // selected randomly for the cells with same count int index = rand() % existChars.size(); return existChars[index]; }
//根据PackID,获取文件列表,检查本地是否已经存在了。 bool CGroupPackFileDownloadWnd::Initialize(sPackItem* pPackItem) { if (NULL == pPackItem) { return false; } //新建cache数据包的数据信息 m_pCurrPackItem = new sPackItem; m_pCurrPackItem->listFile = pPackItem->listFile; m_pCurrPackItem->strPackID = pPackItem->strPackID; m_pCurrPackItem->strPackName = pPackItem->strPackName; m_pCurrPackItem->strPackProp = pPackItem->strPackProp; m_pCurrPackItem->strPackSender = pPackItem->strPackSender; m_pCurrPackItem->strPackSize = pPackItem->strPackSize; m_pCurrPackItem->strPackTime = pPackItem->strPackTime; //初始化标题栏 CControlUI* pPackTitle = static_cast<CControlUI*>(m_pPaintManager->FindControl("label_gc_packname")); if (NULL != pPackTitle) { pPackTitle->SetText(pPackItem->strPackName.c_str()); } //初始化文件列表 if (pPackItem->listFile.size()>0) { for (list<sPackFileItem>::iterator it = pPackItem->listFile.begin(); it != pPackItem->listFile.end(); ++it) { sPackFileItem& onePackFile = *it; m_pGroupPackFileList->AddOneItem(onePackFile); } } else { return false; } //检查文件是否已经下载了:如果下载了,就cache到m_mapFile2State,并更新UI if (pPackItem->listFile.size()>0) { tstring strPackDir = CFileHelper::GetPackDir(pPackItem->strPackName, pPackItem->strPackID); for (list<sPackFileItem>::iterator it = pPackItem->listFile.begin(); it != pPackItem->listFile.end(); ++it) { sPackFileItem& oneFile = *it; tstring strFullPathName = strPackDir + it->strFileName; //先判断有没有这个文件了,如有就直接更新状态 "打开"可用 bool bExist = PathFileExists(strFullPathName.c_str()); if (bExist) { DWORD dwFileSize = _tcstoul(it->strFileSizeAccurate.c_str(), NULL, 10); if (getFileSize(strFullPathName) == dwFileSize) { if (!IsExist(strFullPathName)) { ::EnterCriticalSection(&m_csFState); m_mapFile2State.insert(make_pair(strFullPathName, enm_DownState_Finish)); ::LeaveCriticalSection(&m_csFState); //设置进度条为完成了。//说来话长,这个98就表示下载完成了... m_pGroupPackFileList->SetProgress(strFullPathName, 98); } } } } } return true; }
BOOL IsFileExist(LPCTSTR szFilePath) { return IsExist(szFilePath) && !IsDirExist(szFilePath); }
VALUE CRbFont::dm_is_exist(int argc, VALUE name) { SafeStringValue(name); return C2RbBool(IsExist(Kconv::UTF8ToUnicode(RSTRING_PTR(name)))); }
void OpFileSystem::Rename( const NrpText& pathOld, const NrpText& pathNew ) { assert( IsExist( pathOld ) ); _wrename( pathOld.ToWide(), pathNew.ToWide() ); }