Example #1
0
int CSpecialApp::SplitCString1(CString strIn, CSimpleArray<CString>& vec_String, TCHAR division) 
{ 
	vec_String.RemoveAll(); 
	if (!strIn.IsEmpty()) 
	{ 
		int nCount = 0; 
		int nPos = -1; 
		nPos = strIn.Find(division); 
		CString strTemp = strIn; 
		while (nPos != -1) 
		{ 
			CString strSubString = strTemp.Left(nPos);  
			strTemp = strTemp.Right(strTemp.GetLength() - nPos-1);  
			nPos = strTemp.Find(division); 
			nCount++; 
			vec_String.Add(strSubString); 
		} 

		if (nCount == vec_String.GetSize()) 
		{ 
			CString str; 
			int nSize = strIn.ReverseFind(division); 
			str = strIn.Right(strIn.GetLength()-nSize-1); 
			vec_String.Add(str); 
		} 
	} 

	return vec_String.GetSize(); 
} 
Example #2
0
void CInfoDialog::LogInfo(CString sText)
{
	m_LogCtrl.SetLimitText(0x70000000); 
	if (sText.Right(2) == "\r\n")
	{

	}
	else if (sText.Right(1) == "\r")
	{
		sText += "\n";
	}
	else if (sText.Right(1) == "\n")
	{
		sText = sText.Left(sText.GetLength() -1) + "\r\n";
	}
	else
	{
		sText += "\r\n";
	}

	CString sExistingText;
	m_LogCtrl.GetWindowText(sExistingText);

	m_LogCtrl.SetWindowText(sExistingText + sText);

	int iScroll = m_LogCtrl.GetLineCount() - m_LogCtrl.GetFirstVisibleLine() - 4;
	m_LogCtrl.LineScroll(iScroll);

	UpdateHeapInfo();
}
Example #3
0
void CSharedDirsTreeCtrl::FilterTreeAddSubDirectories(CDirectoryItem* pDirectory, CStringList& liDirs, int nLevel){
	// just some sanity check against too deep shared dirs
	// shouldnt be needed, but never trust the filesystem or a recursive function ;)
	if (nLevel > 14){
		ASSERT( false );
		return;
	}
	POSITION pos = liDirs.GetHeadPosition();
	CString strDirectoryPath = pDirectory->m_strFullPath;
	strDirectoryPath.MakeLower();
	while (pos){
		CString strCurrent = thePrefs.shareddir_list.GetNext(pos);
		CString strCurrentLow = strCurrent;
		strCurrentLow.MakeLower();
		if ( (strDirectoryPath.IsEmpty() || strCurrentLow.Find(strDirectoryPath + _T("\\"), 0) == 0) && strCurrentLow != strDirectoryPath){
			if (!FilterTreeIsSubDirectory(strCurrentLow, strDirectoryPath, liDirs)){
				CString strName = strCurrent;
				if (strName.Right(1) == "\\"){
					strName = strName.Left(strName.GetLength()-1);
				}
				strName = strName.Right(strName.GetLength() - (strName.ReverseFind('\\')+1));
				CDirectoryItem* pNewItem = new CDirectoryItem(strCurrent);
				pNewItem->m_htItem = InsertItem(TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, strName, 5, 5, 0, 0, (LPARAM)pNewItem, pDirectory->m_htItem, TVI_LAST);
				pDirectory->liSubDirectories.AddTail(pNewItem);
				FilterTreeAddSubDirectories(pNewItem, liDirs, nLevel+1);
		
			}
		}
	}
}
CString COHScriptObject::Serialize() {
  CString result = "##" + _name + "##\r\n" + _function_text;
  // Make sure that we have at least 2 new-lines at the end
  if (result.Right(2) != "\r\n") {
    result += "\r\n\r\n";
  } else if (result.Right(4) != "\r\n\r\n") {
    result += "\r\n";
  }
  return result;
}
Example #5
0
BOOL PathManager::CopyDir(CString strSrcPath, CString strDstPath)
{ // 创建目标文件夹
	if (strSrcPath.Right(1) == "\\")
	{
		strSrcPath = strSrcPath.Left(strSrcPath.GetLength() - 1);
	}
	if (strDstPath.Right(1) == "\\")
	{
		strDstPath = strDstPath.Left(strDstPath.GetLength() - 1);
	}
	CreateDirectory(strDstPath,NULL);
	CFileFind finder;
	// 打开指定的文件夹进行搜索
	BOOL bWorking = finder.FindFile(strSrcPath + "\\" + "*.*"); 
	while(bWorking) 
	{
		// 从当前目录搜索文件
		bWorking = finder.FindNextFile();
		CString strFileName = finder.GetFileName(); 
		CString strSrc = strSrcPath + "\\" + strFileName;
		CString strDst = strDstPath + "\\" + strFileName;
		// 判断搜索到的是不是"."和".."目录

		if(!finder.IsDots())

		{

			// 判断搜索到的目录是否是文件夹

			if(finder.IsDirectory())

			{

				// 如果是文件夹的话,进行递归

				if(!CopyDir(strSrc, strDst)) 
				{
					return false;
				}
			}
			else
			{
				// 如果是文件,进行复制
				if(!CopyFile(strSrc, strDst, FALSE))
				{
					return false;
				} 
			} 
		}
	}       
	return true;
} 
Example #6
0
void CLotteryDlg::_readInit()
{
	TCHAR path[MAX_PATH] = {0};
	CString strPath = _getCurPath() + _T("init.ini");
	GetPrivateProfileString(_T("Titile"), _T("title"), _T(""), path, MAX_PATH, strPath);
	CString str = path;
	m_uiInfo._title = str.GetBuffer();
	str.ReleaseBuffer();
	//读取已经中奖的人
	TCHAR *pBuf = new TCHAR[10240];
	memset(pBuf, 0, sizeof(TCHAR) * 10240);
	GetPrivateProfileString(_T("Procedure"), _T("winner"), _T(""), pBuf, 10240, strPath);
	std::wstring strwinner = pBuf;
	delete pBuf;
	pBuf = NULL;
	_parseWinnerPicPath(strwinner);
	//读取奖项设置
	m_TotalClass = GetPrivateProfileInt(_T("Adwards"), _T("total"), 3, strPath);
	m_NumFinished = GetPrivateProfileInt(_T("Procedure"), _T("finished"), 0, strPath);
	AwardInfo ai;
	CString tmp;
	int pos = 0;
	for (int i = m_TotalClass; i > 0; --i)
	{
		str.Format(_T("%d"), i);
		GetPrivateProfileString(_T("Adwards"), str, _T("0"), path, MAX_PATH, strPath);
		str = path;
		//几等奖品
		pos = str.Find(_T(' '));
		tmp = str.Left(pos);
		str = str.Right(str.GetLength() - pos);
		str.TrimLeft();
		ai._class = tmp.GetBuffer();
		tmp.ReleaseBuffer();
		//多少人的
		pos = str.Find(_T(' '));
		tmp = str.Left(pos-1);
		str = str.Right(str.GetLength() - pos);
		str.TrimLeft();
		ai._tnum = _wtoi(tmp.GetBuffer());
		tmp.ReleaseBuffer();
		//什么奖品
		str.Trim();
		ai._award = str.GetBuffer();
		str.ReleaseBuffer();

		m_AwardInfo.push_back(ai);
	}
	//读取信息后需要在做一下处理:比如说上次程序运行已经完成到什么阶段,现在应该接着运行
	_checkFinishedNum();
}
Example #7
0
// static method
git_wc_status_kind GitStatus::GetAllStatus(const CTGitPath& path, git_depth_t depth)
{
	git_wc_status_kind			statuskind;
//	git_client_ctx_t * 			ctx;

//	apr_pool_t *				pool;
//	git_error_t *				err;
	BOOL						err;
	BOOL						isDir;
	CString						sProjectRoot;

	isDir = path.IsDirectory();
	if (!path.HasAdminDir(&sProjectRoot))
		return git_wc_status_none;

//	pool = git_pool_create (NULL);				// create the memory pool

//	git_error_clear(git_client_create_context(&ctx, pool));

//	git_revnum_t youngest = Git_INVALID_REVNUM;
//	git_opt_revision_t rev;
//	rev.kind = git_opt_revision_unspecified;
	statuskind = git_wc_status_none;

	const BOOL bIsRecursive = (depth == git_depth_infinity || depth == git_depth_unknown); // taken from SVN source

	CString sSubPath;
	CString s = path.GetWinPathString();
	if (s.GetLength() > sProjectRoot.GetLength())
	{
		if (sProjectRoot.GetLength() == 3 && sProjectRoot[1] == _T(':'))
			sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());
		else
			sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);
	}

	bool isfull = ((DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\CacheType"),
				GetSystemMetrics(SM_REMOTESESSION) ? ShellCache::dll : ShellCache::exe) == ShellCache::dllFull);

	if(isDir)
	{
		err = GetDirStatus(sProjectRoot,sSubPath,&statuskind, isfull,bIsRecursive,isfull,NULL, NULL);

	}
	else
	{
		err = GetFileStatus(sProjectRoot,sSubPath,&statuskind,isfull, false,isfull, NULL,NULL);
	}

	return statuskind;
}
Example #8
0
bool CSharedDirsTreeCtrl::FileSystemTreeIsShared(CString strDir)
{
	if (strDir.Right(1) != _T('\\'))
		strDir += _T('\\');
	for (POSITION pos = m_strliSharedDirs.GetHeadPosition(); pos != NULL; )
	{
		CString str = m_strliSharedDirs.GetNext(pos);
		if (str.Right(1) != _T('\\'))
			str += _T('\\');
		if (str.CompareNoCase(strDir) == 0)
			return true;
	}
	return false;
}
bool CDirectoryTreeCtrl::IsShared(CString strDir)
{
	if (strDir.Right(1) != _T('\\'))
		strDir += _T('\\');
	for (POSITION pos = m_lstShared.GetHeadPosition(); pos != NULL; )
	{
		CString str = m_lstShared.GetNext(pos);
		if (str.Right(1) != _T('\\'))
			str += _T('\\');
		if (str.CompareNoCase(strDir) == 0)
			return true;
	}
	return false;
}
Example #10
0
void MYIniReadTools::GetKeyAndValue(CString &strKey,CString &strValue,CString &strComment,CString str)
{
	int nComment=str.Find(';',0);
	if (nComment!=-1)
	{
		if (str.Find('"',nComment)==-1)
		{
			strComment=str.Right(str.GetLength()-nComment-1);
			str=str.Left(nComment);
		}
	}
	int nEquale=str.Find('=',0);
	strKey=str.Left(nEquale);
	strValue=str.Right(str.GetLength()-nEquale-1);
}
//输入信息
void CDlgInsureGame::OnEnChangeInCount()
{
	//状态效验
	if(!m_pMeUserData) return;

	//获取数据
	CString strCount;
	GetDlgItem(IDC_IN_COUNT)->GetWindowText(strCount);

	//去掉前面的0
	CString strLeft = strCount.Left(1);
	if(strLeft.Find('0') != -1)
	{
		strCount = strCount.Right(strCount.GetLength() - 1);
		SetDlgItemText(IDC_IN_COUNT,strCount);
	}

	//设置信息
	SCORE lInCount=(m_bBankStorage)?m_lGameGold:m_lStorageGold;
	MakeStringToNum(strCount, m_lInCount);
	if((m_lInCount > lInCount || m_lInCount < 0L))
	{
		m_lInCount = lInCount;
		CString strlGameGold;
		MakeString(strlGameGold,m_lInCount);
		SetDlgItemText(IDC_IN_COUNT,strlGameGold);
	}

	return ;
}
Example #12
0
CString    ReturnExtName( CString pathName )
{   
	int    nPos;   
	nPos=pathName.ReverseFind('\\');   
	pathName=pathName.Right(pathName.GetLength() - nPos - 1);   
	return    pathName;   
}
bool CFilterBlacklist::CFilterBlacklistEntry::Matches(const CLSID& clsid, const CString& filtername) const
{
    if(!IsEqualCLSID(m_clsid,CLSID_NULL))
        return IsEqualCLSID(m_clsid, clsid) != 0;

    if(filtername.IsEmpty() || m_wildcard.IsEmpty()) return false;

	int nLength = m_wildcard.GetLength();
	if (m_wildcard[nLength - 1] == _T('*')) // starts with
	{
        CString strPrefix, strName;

        if(m_wildcard[0] == _T('*'))    // contains
        {
            strPrefix = m_wildcard.Mid(1,nLength - 2);
            strPrefix.MakeLower();
            strName = filtername;
            strName.MakeLower();
            return strName.Find(strPrefix) >= 0;
        }

		strPrefix = m_wildcard.Left(nLength - 1);
		strName = filtername.Left(nLength - 1);
		return strName.CompareNoCase(strPrefix) == 0;
	}
    else if (m_wildcard[0] == _T('*'))  // ends with
    {
        CString strPrefix = m_wildcard.Right(nLength - 1);
		CString strName = filtername.Right(nLength - 1); // Praefix-Length
		return strName.CompareNoCase(strPrefix) == 0;
    }

	return filtername.CompareNoCase(m_wildcard) == 0;
}
Example #14
0
size_t CIniFile::ReadSection(const tchar* pszSection, CStrArray& astrKeys, CStrArray& astrValues)
{
	ASSERT(pszSection);

	CStrArray astrEntries;

	// Read all the entries...
	if (ReadSection(pszSection, astrEntries))
	{
		// Split all entries.
		for (size_t i = 0; i < astrEntries.Size(); ++i)
		{
			// Split into key and value.
			CString strEntry = astrEntries[i];
			size_t  nLength  = strEntry.Length();
			size_t  nSepPos  = strEntry.Find(TXT('='));

			// Key set AND value set?
			if ( (nSepPos > 0) && ((nLength-nSepPos-1) > 0) )
			{
				astrKeys.Add(strEntry.Left(nSepPos));
				astrValues.Add(strEntry.Right(nLength-nSepPos-1));
			}
		}
	}

	ASSERT(astrKeys.Size() == astrValues.Size());

	return astrKeys.Size();
}
Example #15
0
//截取Key
void CINIsoc::CutString(char* fid, int len, ATF_MAP& f_map)
{
	char *pline_head = fid;
	int readtotal = 0;
	for(int i=0;i<len;i++)
	{
		if(fid[i] == 0x0)
		{
			CString str ;
			str.Format("%s",pline_head);
			//读取key对应的数据
			str.Trim();
			if( !str.IsEmpty() )
			{
				CString sKey,sVal;
				int curpos = 0;
				sKey = str.Tokenize("=",curpos);
				sVal = str.Right(str.GetLength()-curpos);
				sKey.MakeUpper(); //统一大写 2011.10.17
				sVal.Trim();
				f_map.insert( ATF_PAIRMAP( sKey, sVal ) );
			}
			if(fid[i+1] == 0x0)
				break;//字段结束;
			pline_head = fid+i+1;
		}
	}
}
Example #16
0
CString GetExtNameFromFull(CString FullName)
{
	int index = FullName.ReverseFind('.');
	if(index<0)
		return "";
	return FullName.Right(FullName.GetLength()-index-1);
}
Example #17
0
void CWndDay::Draw(CRect &rect, CDC *pDC)
{
   CFont* pOldPen = pDC->SelectObject(&m_fontItem);
   pDC->SetBkMode(TRANSPARENT);
   CString str = m_pDateItem->outputString();
   int findpos = -1;
   std::vector<CString> outputVector;
   while ( (findpos = str.Find(L"|")) != -1)
   {
      CString strSub = str.Left(findpos);
      str = str.Right(str.GetLength()-findpos-1);
      outputVector.push_back(strSub);
   }
   outputVector.push_back(str);
   COLORREF oldColor = pDC->SetTextColor(RGB(0, 0, 0));
   if (m_bselected)
   {
      pDC->FillSolidRect(rect, COLORREF_SELECT);
      pDC->SetTextColor(RGB(0, 0, 182));
   }
   CRect rectText = rect;
   if (((int)outputVector.size())>1 && ((int)outputVector.size()) * 20 <= rectText.Height())
   {
      rectText.bottom = rectText.top + 20;
   }
   for (size_t i = 0;i<outputVector.size();++i)
   {
      pDC->DrawText(outputVector[i], rectText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
      rectText.OffsetRect(0, 20);
   }

   pDC->SelectObject(pOldPen);
   pDC->SetTextColor(oldColor);
}
Example #18
0
bool CBrowseRefsDlg::PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind)
{
	CString origRef;
	pComboBox->GetLBText(pComboBox->GetCurSel(), origRef);
	CString resultRef = PickRef(false,origRef,pickRef_Kind);
	if(resultRef.IsEmpty())
		return false;
	if(wcsncmp(resultRef,L"refs/",5)==0)
		resultRef = resultRef.Mid(5);
//	if(wcsncmp(resultRef,L"heads/",6)==0)
//		resultRef = resultRef.Mid(6);

	//Find closest match of choice in combobox
	int ixFound = -1;
	int matchLength = 0;
	CString comboRefName;
	for(int i = 0; i < pComboBox->GetCount(); ++i)
	{
		pComboBox->GetLBText(i, comboRefName);
		if(comboRefName.Find(L'/') < 0 && !comboRefName.IsEmpty())
			comboRefName.Insert(0,L"heads/"); // If combo contains single level ref name, it is usualy from 'heads/'
		if(matchLength < comboRefName.GetLength() && resultRef.Right(comboRefName.GetLength()) == comboRefName)
		{
			matchLength = comboRefName.GetLength();
			ixFound = i;
		}
	}
	if(ixFound >= 0)
		pComboBox->SetCurSel(ixFound);
	else
		ASSERT(FALSE);//No match found. So either pickRef_Kind is wrong or the combobox does not contain the ref specified in the picker (which it should unless the repo has changed before creating the CBrowseRef dialog)

	return true;
}
Example #19
0
//********************************************
// ReadFile
// Redirection
//********************************************
int CTexture::ReadFile(char *filename,
											 unsigned int width,
											 unsigned int height,
											 unsigned int depth)
{
	// Cleanup
	Free();

	// Storage
	m_FileName = filename;

	// Extension
	CString string = filename;
	string.MakeLower();
	TRACE("CTexture::ReadFile : file : %s\n",filename);
	CString extension = string.Right(4);

	// Redirection BMP
	if(extension == ".bmp")
		return ReadFileBMP(filename);


	// Redirection RAW
	if(extension == ".raw")
		return ReadFileRAW(filename,width,height,depth);

	// Unrecognized file format
	CString message;
	message.Format("CTexture::ReadFile : invalid file redirection : %s\n",filename);
	AfxMessageBox(string);

	return 0;
}
Example #20
0
bool CMountPoints::IsMountPoint(CString path)
{
	if (path.GetLength() < 3 || path[1] != _T(':') || path[2] != _T('\\'))
	{
		// Don't know how to make out mount points on UNC paths ###
		return false;
	}

	ASSERT(path.GetLength() >= 3);
	ASSERT(path[1] == _T(':'));
	ASSERT(path[2] == _T('\\'));

	if (!m_va.IsSupported())
		return false;

	if (path.Right(1) != _T('\\'))
		path+= _T("\\");

	path.MakeLower();

	CString volume= m_drive[path[0] - _T('a')];
	path= path.Mid(3);

	return IsVolumeMountPoint(volume, path);
}
Example #21
0
//日志文件清理
void CWriteLogThread::CheckCleanupFileLogFile()
{
    if(m_nLogFileCleanupDate == 0)
    {
        return;
    }

     COleDateTime time1,time2;
     COleDateTimeSpan time3;
     time2 = COleDateTime::GetCurrentTime();
     int nYear,nMonth,nDate;
     
     sscanf(m_strLastCleanupLogFileDate, "%d:%d:%d",&nYear,&nMonth,&nDate);
     time1.SetDate(nYear,nMonth,nDate);
 
     time3 = time2 - time1;
     int nRunData = time3.GetDays();

    //程序连续运行m_nLogFileCleanupDate天进行一次日志文件清理,保存前一天的日志
    //m_nLogFileCleanupDate可以调用SetLogFileCleanupDate()函数设置
    if(nRunData >= m_nLogFileCleanupDate) //
    {
        m_strLastCleanupLogFileDate = CTime::GetCurrentTime().Format("%Y:%m:%d");

        CFileFind tempFileFind;
	    CString szDir = m_strAppLogDir;
	    CString strTitle;
	    CFile file;

	    if(szDir.Right(1) != _T("\\"))
        {
		    szDir += _T("\\");
        }
	    szDir += _T("*.txt");

	    BOOL res = tempFileFind.FindFile(szDir);

        CString strYesterdayLogName;

        CTime time =CTime::GetCurrentTime() - CTimeSpan(1,0, 0,0);
        strYesterdayLogName = time.Format("%Y%m%d"); //前一天的日期
        CString strDeleteFilePath;
	    while( res )
	    {
		    res = tempFileFind.FindNextFile();
		    if(!tempFileFind.IsDirectory() && !tempFileFind.IsDots())
		    {
			    strTitle = tempFileFind.GetFileName();
                if(strTitle.Find(strYesterdayLogName) == -1) //只保留前一天的日志文件
                {
                    //删除txt文件
                    strDeleteFilePath.Format("%s\\%s",m_strAppLogDir,strTitle);
                    CFile::Remove(strDeleteFilePath);//删除文件
                }
			    
		    }
	    }
	    tempFileFind.Close();
    }
}
Example #22
0
void CSharedDirsTreeCtrl::EditSharedDirectories(CDirectoryItem* pDir, bool bAdd, bool bSubDirectories){
	ASSERT(pDir->m_eItemType == SDI_UNSHAREDDIRECTORY);
	CWaitCursor curWait;
	if (bAdd){
		AddSharedDirectory(pDir->m_strFullPath, bSubDirectories);
	}
	else{
		RemoveSharedDirectory(pDir->m_strFullPath, bSubDirectories);
	}
	FileSystemTreeSetShareState(pDir, bAdd, bSubDirectories);
	FileSystemTreeUpdateBoldState();
	FilterTreeReloadTree();

	// sync with the preferences list
	thePrefs.shareddir_list.RemoveAll();
	POSITION pos = m_strliSharedDirs.GetHeadPosition();
	// copy list
	while (pos){
		CString strPath = m_strliSharedDirs.GetNext(pos);
		if (strPath.Right(1) != "\\"){
			strPath += _T("\\");
		}
		thePrefs.shareddir_list.AddTail(strPath);
	}

	//  update the sharedfiles list
	theApp.emuledlg->sharedfileswnd->Reload();
	thePrefs.Save();
}
LONG CBenubirdAutoProxy::ConvertToPDF(LPCTSTR files)
{
	OutputDebugString(_T("------------------------------------- convert AutoProxy"));

	AFX_MANAGE_STATE(AfxGetAppModuleState());

	CStringList lFileList;
	CString lFiles = files;
	int lPos;
	CString lFile;

	//a tricky solution: if #part1 is true the #part2 is not executed
	while (((lPos = lFiles.Find(_T("####"))) != -1 /*#Part1*/) || ((lPos = lFiles.GetLength()) /*#Part2*/)) 
	{
		lFile = lFiles.Left(lPos);
		if (!lFile.IsEmpty())
			lFileList.AddTail(lFile);
		lFiles = lFiles.Right(lFiles.GetLength() - lPos - 4);
	}

	CConvertToPDFDlg lConvertToPDFDlg(&lFileList);
	lConvertToPDFDlg.DoModal();

	return 0;
}
bool CFormulaParser::VerifyFunctionHeader(CString function_header) {
  // Check correct start of function header 
  // and especially throw warnings on old-style and Shanky-style PPL.
  // Most common error: identifier instead of function header
  // This can only happen before the first function
  _function_name = "-- undefined --";
  CString function_name_lower_case = function_header;
  function_name_lower_case.MakeLower();
  if (function_name_lower_case.Left(6) == "custom") {
    CParseErrors::Error("Superfluous keyword custom.\n"
      "OpenPPL 7.0 is somewhat different than old-style OpenPPL and Shanky-PPL.\n"
      "Please have a look at the manual for all the differences.\n"
      "It really matters!\n");
    return false;
  } else if ((function_name_lower_case.Left(7) == "preflop")
	    || (function_name_lower_case.Left(4) == "flop")
	    || (function_name_lower_case.Left(4) == "turn")
	    || (function_name_lower_case.Left(5) == "river")) {
    CParseErrors::Error("Shanky-style betrounds.\n"
      "OpenHoldem-style function expected.\n"
      "Example: ##f$preflop##\n");
    return false;
  } else if (function_name_lower_case.Left(3) == "new") {
    CParseErrors::Error("Old-style OpenPPL function.\n"
      "OpenHoldem-style ##f$function## expected.\n");
    return false;
  } else if ((function_name_lower_case.Left(2) == "//")
      || (function_name_lower_case.Left(2) == "/*")) {
    CParseErrors::Error("Top-level comment outside function.\n"
      "Technically a formula-file is a set of functions\n"
      "and every comment belongs to such a function.\n"
      "A top-level comment outside of a function would get lost.\n"
      "Please put it for example into \"##notes##\".\n");
    return false;
  } else if (function_name_lower_case.Left(2) != "##") {
    CParseErrors::Error("Shanky-style option settings?\n"
      "Options are not supported, because OpenPPL does not provide a default bot.\n"
      "They need to be removed.\n"
      "Expecting a ##f$function## or ##listXYZ## instead.\n");
    return false;
  }
  // Leading ## found
  if (function_name_lower_case.Right(2) != "##") {
    CParseErrors::Error("Malformed function-header. Trailing ## expected.\n");
    return false;
  }
  // New header verified
  _function_name = function_header;
  // Get rid pf ## at both ends
  int length = _function_name.GetLength();
  assert(length >= 4);
  _function_name = _function_name.Left(length - 2);
  _function_name = _function_name.Right(length - 4);
  if (_function_name.GetLength() <= 0) {
    CParseErrors::Error("Empty function or list name.\n"
      "Expecting a ##f$function## here.\n");
    return false;
  }
  return VerifyFunctionNamingConventions(_function_name);
}
Example #25
0
CShadowTree* CShadowTree::FindLeaf(CString partialRefName)
{
	if(IsLeaf())
	{
		if(m_csRefName.GetLength() > partialRefName.GetLength())
			return NULL;
		if(partialRefName.Right(m_csRefName.GetLength()) == m_csRefName)
		{
			//Match of leaf name. Try match on total name.
			CString totalRefName = GetRefName();
			if(totalRefName.Right(partialRefName.GetLength()) == partialRefName)
				return this; //Also match. Found.
		}
	}
	else
	{
		//Not a leaf. Search all nodes.
		for(TShadowTreeMap::iterator itShadowTree = m_ShadowTree.begin(); itShadowTree != m_ShadowTree.end(); ++itShadowTree)
		{
			CShadowTree* pSubtree = itShadowTree->second.FindLeaf(partialRefName);
			if(pSubtree != NULL)
				return pSubtree; //Found
		}
	}
	return NULL;//Not found
}
void COrbitSupplier::retrieveOrbitDownloadList(CString& sDldList) const
{
	CString sMsg;

	
	CString sPath;
	retreivePathToOrbitAppData(sPath);

	ASSERT(sPath.GetLength() > 0);

	sPath.Replace("/", "\\"); 
	if (sPath.Right(1) != "\\") {
		sPath += "\\";
	}

	CString sDldListFilePath = sPath;
	sDldListFilePath += "Orbit\\DownloadList.dat";

	
	if (GetFileAttributes(sDldListFilePath) == (DWORD)(-1)) {
		sMsg = LS (L_CANT_FIND_ORBIT_DOWNLOAD_LIST);
		throw std::runtime_error((const char*)sMsg);
	}

	
	ReadOrbitDldList(sDldListFilePath, sDldList);
}
Example #27
0
void CAirportsManager::GetAirportCoordinates(const CString strAirport, CLatitude& tlat, CLongitude& tlong )
{
	int iAirportIndex = FindOrAddEntry(strAirport);

	CString strCorrd;
	if(iAirportIndex >= 0 )
	{
		CAirport * pAirport =  GetAirportList()->at(iAirportIndex);
		ASSERT(pAirport);
		if(pAirport)
			strCorrd = pAirport->m_sARPCoordinates;
	}
	//get lat long form str;
	if( strCorrd.CompareNoCase("") !=0 )
	{
		CString strLongitude;
		CString strLatitude;
		int nIndex = strCorrd.Find("-");
		strLongitude = strCorrd.Left(nIndex);
		tlong.SetValue(strLongitude);
		strLatitude  = strCorrd.Right(strCorrd.GetLength() - nIndex-1);
		tlat.SetValue(strLatitude);
	}

}
Example #28
0
void AssignSound()
{
  CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
  AddSlash(strBasePath);
  CString strPath = strBasePath;
  strPath += "sound\\";

  CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Sound files (*.wav,*.mp3)|*.wav;*.mp3||", g_pParentWnd);
  dlgFile.m_ofn.lpstrInitialDir = strPath;
  if (dlgFile.DoModal() == IDOK)
  {
	  SendMessage(hwndEnt[EntKeyField], WM_SETTEXT, 0, (LPARAM)"noise");	
    CString str = dlgFile.GetPathName().GetBuffer(0);
    str.MakeLower();
    strBasePath.MakeLower();
    QE_ConvertDOSToUnixName(str.GetBuffer(0), str.GetBuffer(0));
    QE_ConvertDOSToUnixName(strBasePath.GetBuffer(0), strBasePath.GetBuffer(0));
    int n = str.Find(strBasePath);
    if (n == 0)
    {
      str = str.Right(str.GetLength() - strBasePath.GetLength());
    }

	  SendMessage(hwndEnt[EntValueField], WM_SETTEXT, 0, (LPARAM)str.GetBuffer(0));	
    AddProp();
    g_pParentWnd->GetXYWnd()->SetFocus();
  }
}
void CProcessWatchThread::SetConfig(CString path, LPCTSTR lpszEXE)
{
	strEXE = lpszEXE;
	m_strPath = path;
	int idx = path.ReverseFind(_T('\\'));
	strDLL = path.Right(path.GetLength() - idx - 1);
}
bool COrbitSupplier::retrieveDownloadFilePath(const TOrbitDownload& tOrbitDownload, CString& sDownloadFilePath) const
{
	
	sDownloadFilePath = tOrbitDownload.sPath;
	sDownloadFilePath.Replace("/", "\\");
	if (sDownloadFilePath.IsEmpty()) {
		
		return false;
	}

	if (sDownloadFilePath.Right(1) != "\\") {
		sDownloadFilePath += "\\";
	}

	CString sDownloadFileName = tOrbitDownload.sFile;
	if (!tOrbitDownload.bIsComplete) {
		sDownloadFileName += ".ob!"; 
	}

	if (sDownloadFileName.IsEmpty()) {
		
		return false;
	}

	sDownloadFilePath += sDownloadFileName;
	if (GetFileAttributes(sDownloadFilePath) == (DWORD)(-1)) {
		
		return false;
	}

	return true;
}