Beispiel #1
0
//打开指定数据库对象连接
int CCommDBOper::ADOOpenDBCon(_ConnectionPtr &pCon,const CString strDBPathName,
							  const CString strDBFileName,CString &strPassword,int iWarn)
{
	//函数功能   打开指定数据库
	//输入参数说明   pCon 要打开的数据库对象,strDBPathName 要连接的ACCESS数据库文件目录
	//				strDBFileName 要打开的数据库文件名,strPassword  密码
	//				iWarn 出错警告方式  0,不警告,1,警告,2,警告且退出程序
	//作者  LFX
	CString tstrDBPathName;
	tstrDBPathName = strDBPathName;
	
	if (!strDBFileName.IsEmpty()) 
	{
		//目录是否合法
		int iret1;
		iret1 = tstrDBPathName.FindOneOf("*?\"<>|");
		if (iret1 != -1)
		{
			CString strTemp;
			strTemp.Format("数据库(%s)的目录(%s)非法!!!",strDBFileName,strDBPathName);
			WarnMessage(strTemp,iWarn);
			return RET_FAILED;
		}
		
		iret1 = tstrDBPathName.ReverseFind('\\');
		if (iret1  != 1)
		{
			tstrDBPathName += "\\";
		}
	}

	CString strDB;
	strDB.Empty();
	strDB += tstrDBPathName;
	strDB += strDBFileName;
	return ADOOpenDBCon(pCon,strDB,strPassword,iWarn);
}
Beispiel #2
0
void CSubdivisionDoc::OnImport()
{
	CString lpszFilter = _T("Obj files (*.obj)|*.obj|Off files (*.off)|*.off||");
	CFileDialog dlg(true, NULL, NULL, OFN_READONLY, lpszFilter);
	dlg.m_ofn.lpstrTitle = _T("Import 3D model");		////
	dlg.m_ofn.lpstrDefExt = _T("obj");		

	if(dlg.DoModal() == IDOK)
	{
		CString		strFile = dlg.GetPathName();

		//	delete  m_pmesh, m_pmesh = NULL;
		if (m_pmesh==NULL) {
			m_pmesh = new Mesh3D;
		}

		CString extension = strFile;
		extension = extension.Right(extension.GetLength()-extension.ReverseFind('.'));
		extension.MakeLower();

		if (extension == ".off")
		{
			CStringA   ss(strFile);
			m_pmesh->load_off((LPCSTR)(ss));
		}
		else if (extension == ".obj")
		{
			//const char * ss = CString2constchar(strFile);
			CStringA  ss(strFile);
			m_pmesh->load_obj((LPCSTR)(ss));
		}

		m_pmesh->update_mesh();

	}
	UpdateAllViews(NULL);
}
Beispiel #3
0
LRESULT CJobsConfigure::OnP4Describe( WPARAM wParam, LPARAM lParam )
{
	CCmd_Describe *pCmd = ( CCmd_Describe * )wParam;

	MainFrame()->ClearStatus();
	if(!pCmd->GetError())
	{
		int i;
		CString desc = MakeCRs( pCmd->GetDescription( ) );
		if ((i = desc.ReverseFind(_T('#'))) != -1)
		{
			if ((i = desc.Find(_T('\n'), i)) != -1)
				desc = desc.Left(i+1);
		}
		int key;
		CSpecDescDlg *dlg = new CSpecDescDlg(this);
		dlg->SetIsModeless(TRUE);
		dlg->SetKey(key = pCmd->HaveServerLock()? pCmd->GetServerKey() : 0);
		dlg->SetDescription( desc, FALSE );
		dlg->SetCaption( LoadStringResource(IDS_P4WIN_SPECIFICATION_NOTES) );
		dlg->SetWinPosName(_T("JobSpecInfo"));
		CRect rect;
		GetWindowRect(&rect);
		rect.top += rect.Height() - 10;
		rect.bottom = GetSystemMetrics(SM_CYFULLSCREEN);
		rect.right  = GetSystemMetrics(SM_CXFULLSCREEN);
		dlg->SetWinPosDefault(rect);
		if (!dlg->Create(IDD_SPECDESC, this))	// display the description dialog box
		{
			dlg->DestroyWindow();	// some error! clean up
			delete dlg;
		}
	}
	delete pCmd;
	GotoDlgCtrl(GetDlgItem(IDC_LIST_OTHER));
	return 0;
}
static LONG makeKey(HKEY root, const CString & path, HKEY * key)
    {
     LONG result = ::RegOpenKey(root, path, key);
     if(result == ERROR_SUCCESS)
	return result;

     // We have a path of the form a\b\c\d  
     // But apparently a/b/c doesn't exist

     int i = path.ReverseFind(_T('\\'));
     if(i == -1)
	return result;  // well, we lose

     CString s;
     s = path.Left(i);

     HKEY newkey;
     result = makeKey(root, s, &newkey);
     if(result != ERROR_SUCCESS)
	return result;

     // OK, we now have created a\b\c
     CString v;
     v = path.Right(path.GetLength() - i - 1);
     DWORD disp;

     result = ::RegCreateKeyEx(newkey, 
     				v,
				0, NULL,
				REG_OPTION_NON_VOLATILE,
				KEY_ALL_ACCESS,
				NULL,
				key,
				&disp);
     ::RegCloseKey(newkey); // no longer needed                     // REQ #278
     return result;
    }
Beispiel #5
0
BOOL CCrashInfoReader::UpdateUserInfo(CString sEmail, CString sDesc)
{
	// This method validates user-provided Email and problem description
	// and (if valid) uptdates internal fields.
	BOOL bResult = TRUE;

	// If an email address was entered, verify that
    // it [1] contains a @ and [2] the last . comes
    // after the @.
    
    if (sEmail.GetLength()!=0 &&
        (sEmail.Find(_T('@')) < 0 ||
        sEmail.ReverseFind(_T('.')) < 
        sEmail.Find(_T('@'))))
    {
        // Invalid email            
		bResult = FALSE;
    }
	else
	{
		// Update email
		GetReport(0)->m_sEmailFrom = sEmail;
	}

	// Update problem description
	GetReport(0)->m_sDescription = sDesc;	

    // Write user email and problem description to XML
    AddUserInfoToCrashDescriptionXML(
        GetReport(0)->m_sEmailFrom, 
        GetReport(0)->m_sDescription);

	// Save E-mail entered by user to INI file for later reuse.
	SetPersistentUserEmail(sEmail);

	return bResult;
}
Beispiel #6
0
CmdwEditorDoc::CmdwEditorDoc()
{
	// TODO: add one-time construction code here
	TCHAR buf[1024];

	::GetModuleFileName(NULL, buf, sizeof(buf));
	TRACE( _T("exe path = %s\n"), buf);

	CString tmp = CString(buf);
	int idx = tmp.ReverseFind('\\');
	if(idx > 0) {
		m_AppPath = tmp.Left(idx+1);
	}
	else {
		m_AppPath = tmp + _T('\\');
		::CreateDirectory(m_AppPath, NULL);
	}

	m_cssPath = m_AppPath + _T("mdwdefault.css");
	m_htmlPath = m_AppPath + _T("preview_001.html");
	m_bHtmlExisted = FALSE;

	checkDefaultCSS();
}
Beispiel #7
0
BOOL CIniEx::OpenAtExeDirectory(LPCTSTR pFileName,
							BOOL writeWhenChange,/*=TRUE*/
							BOOL createIfNotExist/*=TRUE*/,
							BOOL noCaseSensitive /*=TRUE*/,
							BOOL makeBackup      /*=FALSE*/)
{

	CString filePath;
//if it's a dll argv will be NULL and it may cause memory leak	
#ifndef _USRDLL
	CString tmpFilePath;
	int nPlace=0;
	tmpFilePath=__argv[0];
	nPlace=tmpFilePath.ReverseFind('\\');
	
	
	if (nPlace!=-1)
	{
		filePath=tmpFilePath.Left(nPlace);
	}
	else
	{
		TCHAR curDir[MAX_PATH];
		GetCurrentDirectory(MAX_PATH,curDir);
		filePath=curDir;
	}
#else
	//it must be safe for dll's
	TCHAR curDir[MAX_PATH];
	GetCurrentDirectory(MAX_PATH,curDir);
	filePath=curDir;
#endif
	filePath+="\\";
	filePath+=pFileName;
	return Open(filePath,writeWhenChange,createIfNotExist,noCaseSensitive,makeBackup);
}
Beispiel #8
0
LRESULT CLabelListCtrl::OnDoLabelDelFiles(WPARAM wParam, LPARAM lParam)
{
	BOOL preview = FALSE;
	if (wParam == IDOK)
	{
		preview = lParam;
		if (m_DelSyncList.GetCount())
		{
			POSITION pos2;
			for (POSITION pos1 = m_DelSyncList.GetHeadPosition(); ( pos2 = pos1 ) != NULL; )
			{
				CString str = m_DelSyncList.GetNext(pos1);
				int i = str.ReverseFind(_T('#'));
				if (i != -1)
					str = str.Left(i);
				str += _T("#none");
				m_DelSyncList.SetAt(pos2, str);
			}
			CCmd_LabelSynch *pCmd= new CCmd_LabelSynch;
			pCmd->Init( m_hWnd, RUN_ASYNC);
			if( pCmd->Run( m_DelSyncName, &m_DelSyncList, preview, FALSE, FALSE ) )
				MainFrame()->UpdateStatus( LoadStringResource(IDS_SYNCING_LABEL) );	
			else
				delete pCmd;
		}
		else
			AddToStatus(LoadStringResource(IDS_NOTHING_SELECTED_NOTHING_TO_DO));
	}
	if (m_DelSyncDlg && !preview)
	{
		m_DelSyncDlg->DestroyWindow();	// deletes m_DelSyncDlg
		m_DelSyncDlg = 0;
		MainFrame()->SetModelessUp(FALSE);
	}
	return 0;
}
void KAppModule::_InitUIResource()
{

    //BkFontPool::SetDefaultFont(BkString::Get(IDS_APP_FONT), -12);

    if ( TRUE /*_CmdLine.HasParam(L"{69DD4969-E6C4-42d9-A508-105DDA13CE40}")*/)
    {
        CString strPath;

        GetModuleFileName((HMODULE)&__ImageBase, strPath.GetBuffer(MAX_PATH + 10), MAX_PATH);
        strPath.ReleaseBuffer();
        strPath.Truncate(strPath.ReverseFind(L'\\') + 1);
        strPath += L"res\\safeflow";

        if ( PathFileExists(strPath) )
            BkResManager::SetResourcePath(strPath);
    }

    BkFontPool::SetDefaultFont(_T("宋体"), -12);

    BkSkin::LoadSkins(IDR_BK_SKIN_DEF);
    BkStyle::LoadStyles(IDR_BK_STYLE_DEF);
    BkString::Load(IDR_BK_STRING_DEF);
}
BOOL COptionPageLanguage::OnInitDialog()
{
	CMFCPropertyPage::OnInitDialog();

	//Set URLs
	CString DictURL;
	DictURL.LoadString(ID_URL_TCDICTDOWNLOAD);
	int idLastLineBreak = DictURL.ReverseFind(_T('\n'));
	ASSERT(idLastLineBreak > 0);
	m_wndURLDownloadDicts.SetURL(DictURL.Mid(idLastLineBreak + 1));
	m_wndURLDownloadDicts.SizeToContent(true,true);

	FindDictionaries();
	CComboBox *pLangBox = (CComboBox*)GetDlgItem(IDC_OPTIONS_LANGUAGE);

	// Add all the found languages
	for (int i = 0; i < m_aLanguage.GetSize(); ++i)
	{
		if (pLangBox->FindString(0,m_aLanguage[i]) == CB_ERR)
			pLangBox->AddString(m_aLanguage[i]);
	}

	// Select the language
	int nSel = pLangBox->FindStringExact(0,m_strLanguageDefault);

	if (nSel == CB_ERR)
		pLangBox->SetCurSel(0);
	else
		pLangBox->SetCurSel(nSel);

	OnSelchangeOptionsLanguage();
	UpdateControlStates();

	return TRUE; // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #11
0
void CFileSelectDlg::OnBnClickedButtonBrowse()
{
    // TODO: Add your control notification handler code here
    CString csEditText;
    m_edtFileName.GetWindowText(csEditText);

    int pos = csEditText.ReverseFind(_T('\\'));
    CString csDefName = _T("");
    if(pos != -1)
    {
        csDefName = csEditText.Right(csEditText.GetLength() - pos - 1);
        csDefName.Left(csDefName.GetLength() - 4);
    }
    static TCHAR szFilter[] = _T("LECTURNITY Source Documents (*.lsd)|*.lsd|All Files (*.*)|*.*||");
    CFileDialog fDlg(false, _T(".lsd"), /*NULL*/csDefName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);

    CString csLsdName;
    if(fDlg.DoModal() == IDOK)
    {
        m_edtFileName.SetWindowText(fDlg.GetPathName());
    }


}
Beispiel #12
0
BOOL CHttpFileDownload::CheckFolder(CString	strPath)
{
	CString strFindPath = strPath;
	CString strTmp;
	BOOL bSuccess = TRUE;
	int nFind = 3;
	int nEnd = strPath.ReverseFind('\\');
	
	HTTP_CANCEL();
	while(nFind <= nEnd && bSuccess)
	{	
		HTTP_CANCEL();
		nFind = strPath.Find('\\', nFind);
		strTmp = strFindPath.Left( nFind );
		bSuccess = CreateCheck(strTmp);
		nFind++;
	}
	
	if(!bSuccess)
		return FALSE;
	
	return TRUE;
/*
	if(_chdir((LPCSTR)(LPCTSTR)strPath) == 0)
		return TRUE;
	else{
		if(_mkdir((LPCSTR)(LPCTSTR)strPath) == 0)
			return TRUE;
		else{
			// ErrMsgBox("Failed to Create Download Directory!");
			return FALSE;
		}

	}
*/
}
Beispiel #13
0
bool CNetWorker::SaveTrainModel(const char* pPath)
{
	Stringoper oper;
	char path[MAX_PATH];
	strcpy_s(path, pPath);
	CString modelpath = oper.chartocstring(path);

	CFile file;
	file.Open(modelpath, CFile::modeWrite|CFile::modeCreate);		//清空原来文件
	file.SetLength(0);
	file.Close();

	if (m_BpNet.m_nTrainArithmetic == 2)						//FANN 模型,保留附加参数
	{
		int index = modelpath.ReverseFind('.');
		if (index != -1)
		{
			modelpath.Insert(index, _T("_Append_"));
		}
		else
			modelpath += _T("_Append_");
	}
	return m_BpNet.SaveWeighttoFile(modelpath);
}
Beispiel #14
0
/////////////////////////////////////////////////////////////////////////////
// data processing
/////////////////////////////////////////////////////////////////////////////
void CDropListCtrl::ProcessData(CString strData)
{
	int idx;
	int iIns;
	int iTab;
	int iIndex;
	CDropStatic *pButton;

	//get the button in question
	pButton = ((CNewGameDialog *) GetParent())->getDropButton();

	//remove the data from the button
	if(pButton) pButton->dropItem();

	//unformat the text
	iTab = strData.ReverseFind('\t');

	//get the index
	idx = atoi(strData.Right(strData.GetLength() - iTab - 1));

	//chop it off
	strData = strData.Left(iTab);
	
	//get the id
	iIndex = atoi(strData);

	//insert the text in
	iIns = InsertItem(GetItemCount(), PLAYERS->getPlayer(iIndex).getCommaName());
	SetItemData(iIns, iIndex);

	//reset the selection
	setSelection();

	//call the sort function
	sort();
}
Beispiel #15
0
BOOL CBuffer::ReadLine(CString& strLine, UINT nCodePage, BOOL bPeek)
{
	DWORD nLength; for ( nLength = 0 ; nLength < m_nLength ; nLength++ )
	{
		if ( m_pBuffer[ nLength ] == '\n' ) break;
	}

	if ( nLength >= m_nLength ) return FALSE;

	int nWide = MultiByteToWideChar( nCodePage, 0, (LPCSTR)m_pBuffer, nLength, NULL, 0 );

	LPWSTR pszWide = new WCHAR[ nWide ];
	MultiByteToWideChar( nCodePage, 0, (LPCSTR)m_pBuffer, nLength, pszWide, nWide );

	strLine = CString(pszWide, nWide);
	delete [] pszWide;

	int nCR = strLine.ReverseFind( '\r' );
	if ( nCR >= 0 ) strLine = strLine.Left( nCR );

	if ( ! bPeek ) Remove( nLength + 1 );

	return TRUE;
}
Beispiel #16
0
void CAutoUpdate::RemoveSelf(const CString &srcFullPath,
							 const CString &desPath,
							 const CString &desFile)
{
	CString strSrcFullPath;
	CString strDesPath;
	CString strDesFile;

	strSrcFullPath = srcFullPath;
	strDesPath = desPath;
	strDesFile = desFile;

	// look like: the temppath is not correct as input parameter in MoveFileEx();
// 	TCHAR strTempPath[MAX_PATH];
// 	GetTempPath(MAX_PATH,strTempPath);
// 	_tcscat(strTempPath,_T("vbupdate.tmp"));
	CFileFind find;
	if( !find.FindFile(strSrcFullPath) )
	{
		find.Close();
		return;
	}
	find.Close();

	CString strDesFullPath = desPath + desFile;
	strDesFullPath = strDesFullPath.Left(strDesFullPath.ReverseFind('\\'));
	strDesFullPath += "\\temp.tmp";

	DeleteFile(strDesFullPath);

	CFile::Rename(desPath+desFile,strDesFullPath);
	CopyFile(strSrcFullPath,desPath+desFile,FALSE);
	MoveFileEx(strDesFullPath,NULL,MOVEFILE_DELAY_UNTIL_REBOOT);

	
}
Beispiel #17
0
void CGnuTransfers::LoadDownloads()
{
	CFileFind finder;
	CString   Header;

	// Start looking for files
	CString PartialPath = m_pPrefs->m_PartialDir;
	int bWorking = finder.FindFile(PartialPath + "\\*");

	while (bWorking)
	{
		bWorking = finder.FindNextFile();

		// Skip . and .. files
		if (finder.IsDots() || finder.IsDirectory())
			continue;


		CString FileDir  = finder.GetFilePath();

		if( FileDir.Right(5).Compare(".info") == 0 )
		{
			CGnuDownloadShell* pDownload = LoadDownloadHosts(FileDir);

			if(pDownload)
			{
				int dotpos = FileDir.ReverseFind('.');
				FileDir = FileDir.Left(dotpos) + ".part";
				
				LoadDownloadParts(FileDir, pDownload);
			}
		}
	}

	finder.Close();
}
CString ProjectProperties::GetBugIDFromLog(CString& msg)
{
	CString sBugID;

	if (!sMessage.IsEmpty())
	{
		CString sBugLine;
		CString sFirstPart;
		CString sLastPart;
		BOOL bTop = FALSE;
		if (nBugIdPos < 0)
			return sBugID;
		sFirstPart = sMessage.Left(nBugIdPos);
		sLastPart = sMessage.Mid(nBugIdPos + 7);
		msg.TrimRight('\n');
		if (msg.ReverseFind('\n')>=0)
		{
			if (bAppend)
				sBugLine = msg.Mid(msg.ReverseFind('\n')+1);
			else
			{
				sBugLine = msg.Left(msg.Find('\n'));
				bTop = TRUE;
			}
		}
		else
		{
			if (bNumber)
			{
				// find out if the message consists only of numbers
				bool bOnlyNumbers = true;
				for (int i=0; i<msg.GetLength(); ++i)
				{
					if (!_istdigit(msg[i]))
					{
						bOnlyNumbers = false;
						break;
					}
				}
				if (bOnlyNumbers)
					sBugLine = msg;
			}
			else
				sBugLine = msg;
		}
		if (sBugLine.IsEmpty() && (msg.ReverseFind('\n') < 0))
		{
			sBugLine = msg.Mid(msg.ReverseFind('\n')+1);
		}
		if (sBugLine.Left(sFirstPart.GetLength()).Compare(sFirstPart)!=0)
			sBugLine.Empty();
		if (sBugLine.Right(sLastPart.GetLength()).Compare(sLastPart)!=0)
			sBugLine.Empty();
		if (sBugLine.IsEmpty())
		{
			if (msg.Find('\n')>=0)
				sBugLine = msg.Left(msg.Find('\n'));
			if (sBugLine.Left(sFirstPart.GetLength()).Compare(sFirstPart)!=0)
				sBugLine.Empty();
			if (sBugLine.Right(sLastPart.GetLength()).Compare(sLastPart)!=0)
				sBugLine.Empty();
			bTop = TRUE;
		}
		if (sBugLine.IsEmpty())
			return sBugID;
		sBugID = sBugLine.Mid(sFirstPart.GetLength(), sBugLine.GetLength() - sFirstPart.GetLength() - sLastPart.GetLength());
		if (bTop)
		{
			msg = msg.Mid(sBugLine.GetLength());
			msg.TrimLeft('\n');
		}
		else
		{
			msg = msg.Left(msg.GetLength()-sBugLine.GetLength());
			msg.TrimRight('\n');
		}
	}
	return sBugID;
}
std::vector<CHARRANGE> ProjectProperties::FindBugIDPositions(const CString& msg)
{
	size_t offset1 = 0;
	size_t offset2 = 0;
	std::vector<CHARRANGE> result;

	// first use the checkre string to find bug ID's in the message
	if (!sCheckRe.IsEmpty())
	{
		if (!sBugIDRe.IsEmpty())
		{

			// match with two regex strings (without grouping!)
			try
			{
				AutoUpdateRegex();
				const std::tr1::wsregex_iterator end;
				std::wstring s = msg;
				for (std::tr1::wsregex_iterator it(s.begin(), s.end(), regCheck); it != end; ++it)
				{
					// (*it)[0] is the matched string
					std::wstring matchedString = (*it)[0];
					ptrdiff_t matchpos = it->position(0);
					for (std::tr1::wsregex_iterator it2(matchedString.begin(), matchedString.end(), regBugID); it2 != end; ++it2)
					{
						ATLTRACE(_T("matched id : %s\n"), (*it2)[0].str().c_str());
						ptrdiff_t matchposID = it2->position(0);
						CHARRANGE range = {(LONG)(matchpos+matchposID), (LONG)(matchpos+matchposID+(*it2)[0].str().size())};
						result.push_back(range);
					}
				}
			}
			catch (std::exception) {}
		}
		else
		{
			try
			{
				AutoUpdateRegex();
				const std::tr1::wsregex_iterator end;
				std::wstring s = msg;
				for (std::tr1::wsregex_iterator it(s.begin(), s.end(), regCheck); it != end; ++it)
				{
					const std::tr1::wsmatch match = *it;
					// we define group 1 as the whole issue text and
					// group 2 as the bug ID
					if (match.size() >= 2)
					{
						ATLTRACE(_T("matched id : %s\n"), std::wstring(match[1]).c_str());
						CHARRANGE range = {(LONG)(match[1].first-s.begin()), (LONG)(match[1].second-s.begin())};
						result.push_back(range);
					}
				}
			}
			catch (std::exception) {}
		}
	}
	else if (result.empty() && (!sMessage.IsEmpty()))
	{
		CString sBugLine;
		CString sFirstPart;
		CString sLastPart;
		BOOL bTop = FALSE;
		if (nBugIdPos < 0)
			return result;

		sFirstPart = sMessage.Left(nBugIdPos);
		sLastPart = sMessage.Mid(nBugIdPos + 7);
		CString sMsg = msg;
		sMsg.TrimRight('\n');
		if (sMsg.ReverseFind('\n')>=0)
		{
			if (bAppend)
				sBugLine = sMsg.Mid(sMsg.ReverseFind('\n')+1);
			else
			{
				sBugLine = sMsg.Left(sMsg.Find('\n'));
				bTop = TRUE;
			}
		}
		else
			sBugLine = sMsg;
		if (sBugLine.Left(sFirstPart.GetLength()).Compare(sFirstPart)!=0)
			sBugLine.Empty();
		if (sBugLine.Right(sLastPart.GetLength()).Compare(sLastPart)!=0)
			sBugLine.Empty();
		if (sBugLine.IsEmpty())
		{
			if (sMsg.Find('\n')>=0)
				sBugLine = sMsg.Left(sMsg.Find('\n'));
			if (sBugLine.Left(sFirstPart.GetLength()).Compare(sFirstPart)!=0)
				sBugLine.Empty();
			if (sBugLine.Right(sLastPart.GetLength()).Compare(sLastPart)!=0)
				sBugLine.Empty();
			bTop = TRUE;
		}
		if (sBugLine.IsEmpty())
			return result;

		CString sBugIDPart = sBugLine.Mid(sFirstPart.GetLength(), sBugLine.GetLength() - sFirstPart.GetLength() - sLastPart.GetLength());
		if (sBugIDPart.IsEmpty())
			return result;

		//the bug id part can contain several bug id's, separated by commas
		if (!bTop)
			offset1 = sMsg.GetLength() - sBugLine.GetLength() + sFirstPart.GetLength();
		else
			offset1 = sFirstPart.GetLength();
		sBugIDPart.Trim(_T(","));
		while (sBugIDPart.Find(',')>=0)
		{
			offset2 = offset1 + sBugIDPart.Find(',');
			CHARRANGE range = {(LONG)offset1, (LONG)offset2};
			result.push_back(range);
			sBugIDPart = sBugIDPart.Mid(sBugIDPart.Find(',')+1);
			offset1 = offset2 + 1;
		}
		offset2 = offset1 + sBugIDPart.GetLength();
		CHARRANGE range = {(LONG)offset1, (LONG)offset2};
		result.push_back(range);
	}

	return result;
}
Beispiel #20
0
void CWorldsDlg::OnWorldDecompress()
{

	//first off, we need to get the filename of the selected item
	CString sInFileName = GetSelectedItemFileName();

	int nDotPos = sInFileName.ReverseFind('.');
	if(nDotPos == -1)
		return;

	CString sExt = sInFileName.Mid(nDotPos + 1);
	if(sExt.CompareNoCase("ltc") != 0)
		return;

	//make sure it is compressed
	if(CLTAUtil::IsFileCompressed(sInFileName) == false)
	{
		//this shouldn't ever happen. The wrong menu item managed to come up
		ASSERT(false);
		return;
	}

	//make sure that the region we are compressing is not open for editing
	for(uint32 nCurrRegion = 0; nCurrRegion < GetProjectBar()->m_RegionDocs.GetSize(); nCurrRegion++)
	{
		if(sInFileName.CompareNoCase(GetProjectBar()->m_RegionDocs[nCurrRegion]->m_FileName) == 0)
		{
			//they are trying to compress a file that is open, we can't allow this, otherwise
			//when they save, it will save to the wrong filename. Another approach
			//would be to update the region's filename, but I don't think I'll have enough
			//time to thoroughly test this to my satisfaction, so I'll go with the error
			MessageBox(	sInFileName + " is currently open for editing.\nYou must close this file before you decompress it",
						"Cannot Decompress Open File", MB_ICONEXCLAMATION | MB_OK);
			return;
		}
	}



	CString sOutFileName = ConvertExtension(sInFileName, ".ltc", ".lta");

	//see if the file already exists
	if(DoesFileExist(sOutFileName) == TRUE)
	{
		//prompt the user with an overwrite prompt
		if(MessageBox("The file " + sOutFileName + " already exists.\nWould you like to overwrite this file?",
					"File already exists", MB_ICONQUESTION | MB_YESNO) == IDNO)
		{
			//the user didn't want to overwrite the file
			return;
		}
	}

	//now we open up the input file, and compress it
	BeginWaitCursor();

	CLTAFile InFile(sInFileName, true, true);
	//make sure the files opened okay
	if(InFile.IsValid() == false)
	{
		MessageBox(	"Unable to open " + sInFileName + " for reading\nDecompression not performed", 
					"Error", MB_ICONEXCLAMATION | MB_OK);
		return;
	}

	CLTAFile OutFile(sOutFileName, false, false);
	//make sure the files opened okay
	if(OutFile.IsValid() == false)
	{
		MessageBox(	"Unable to open " + sOutFileName + " for writing\nDecompression not performed", 
					"Error", MB_ICONEXCLAMATION | MB_OK);
		return;
	}

	//now we just decompress
	uint8 nByte;
	while(InFile.ReadByte(nByte))
	{
		if(OutFile.WriteByte(nByte) == false)
		{
			MessageBox(	"Error while saving to " + sOutFileName + "\nDecompression not performed",
						"Error", MB_ICONEXCLAMATION | MB_OK);
			return;
		}
	}

	//close out the files
	InFile.Close();
	OutFile.Close();

	//now we need to delete the input file
	// Delete the world
	if (!DeleteFile(sInFileName))
	{
		MessageBox("Error deleting world" + sInFileName, "Error", MB_OK | MB_ICONEXCLAMATION);
		return;
	}

	// Refresh the display list
	PopulateList();

	EndWaitCursor();
}
Beispiel #21
0
int CCrashInfoReader::ParseCrashDescription(CString sFileName, BOOL bParseFileItems, CErrorReportInfo& eri)
{
    strconv_t strconv;
    FILE* f = NULL; 

#if _MSC_VER<1400
    f = _tfopen(sFileName, _T("rb"));
#else
    _tfopen_s(&f, sFileName, _T("rb"));
#endif

    if(f==NULL)
        return 1;

    TiXmlDocument doc;
    bool bOpen = doc.LoadFile(f);
    if(!bOpen)
        return 1;

    TiXmlHandle hRoot = doc.FirstChild("CrashRpt");
    if(hRoot.ToElement()==NULL)
    {
        fclose(f);
        return 1;
    }

    {
        TiXmlHandle hCrashGUID = hRoot.FirstChild("CrashGUID");
        if(hCrashGUID.ToElement()!=NULL)
        {
            if(hCrashGUID.FirstChild().ToText()!=NULL)
            {
                const char* szCrashGUID = hCrashGUID.FirstChild().ToText()->Value();
                if(szCrashGUID!=NULL)
                    eri.m_sCrashGUID = strconv.utf82t(szCrashGUID);
            }
        }
    }

    {
        TiXmlHandle hAppName = hRoot.FirstChild("AppName");
        if(hAppName.ToElement()!=NULL)
        {
            const char* szAppName = hAppName.FirstChild().ToText()->Value();
            if(szAppName!=NULL)
                eri.m_sAppName = strconv.utf82t(szAppName);
        }
    }

    {
        TiXmlHandle hAppVersion = hRoot.FirstChild("AppVersion");
        if(hAppVersion.ToElement()!=NULL)
        {
            TiXmlText* pText = hAppVersion.FirstChild().ToText();
            if(pText!=NULL)
            {
                const char* szAppVersion = pText->Value();
                if(szAppVersion!=NULL)
                    eri.m_sAppVersion = strconv.utf82t(szAppVersion);
            }
        }
    }

    {
        TiXmlHandle hImageName = hRoot.FirstChild("ImageName");
        if(hImageName.ToElement()!=NULL)
        {
            TiXmlText* pText = hImageName.FirstChild().ToText();
            if(pText!=NULL)
            {
                const char* szImageName = pText->Value();
                if(szImageName!=NULL)
                    eri.m_sImageName = strconv.utf82t(szImageName);
            }
        }
    }

    {
        TiXmlHandle hSystemTimeUTC = hRoot.FirstChild("SystemTimeUTC");
        if(hSystemTimeUTC.ToElement()!=NULL)
        {
            TiXmlText* pText = hSystemTimeUTC.FirstChild().ToText();
            if(pText!=NULL)
            {
                const char* szSystemTimeUTC = pText->Value();
                if(szSystemTimeUTC!=NULL)
                    eri.m_sSystemTimeUTC = strconv.utf82t(szSystemTimeUTC);
            }
        }
    }

    if(bParseFileItems)
    {
        // Get directory name
        CString sReportDir = sFileName;
        int pos = sFileName.ReverseFind('\\');
        if(pos>=0)
            sReportDir = sFileName.Left(pos);
        if(sReportDir.Right(1)!=_T("\\"))
            sReportDir += _T("\\");

        TiXmlHandle fl = hRoot.FirstChild("FileList");
        if(fl.ToElement()==0)
        {    
            fclose(f);
            return 1;
        }

        TiXmlHandle fi = fl.FirstChild("FileItem");
        while(fi.ToElement()!=0)
        {
            const char* pszDestFile = fi.ToElement()->Attribute("name");      
            const char* pszDesc = fi.ToElement()->Attribute("description");      
			const char* pszOptional = fi.ToElement()->Attribute("optional");      

            if(pszDestFile!=NULL)
            {
                CString sDestFile = strconv.utf82t(pszDestFile);      
                ERIFileItem item;
                item.m_sDestFile = sDestFile;
                item.m_sSrcFile = sReportDir + sDestFile;
                if(pszDesc)
                    item.m_sDesc = strconv.utf82t(pszDesc);
                item.m_bMakeCopy = FALSE;

				if(pszOptional && strcmp(pszOptional, "1")==0)
					item.m_bAllowDelete = true;

                // Check that file really exists
                DWORD dwAttrs = GetFileAttributes(item.m_sSrcFile);
                if(dwAttrs!=INVALID_FILE_ATTRIBUTES &&
                    (dwAttrs&FILE_ATTRIBUTE_DIRECTORY)==0)
                {
                    eri.m_FileItems[sDestFile] = item;
                }
            }

            fi = fi.ToElement()->NextSibling("FileItem");
        }    
    }

    fclose(f);
    return 0;
}
void CWorkSpaceView::InitTreeCtrl() 
{
	if(m_bTreeInited)
	{
		return;
	}
	m_bTreeInited = TRUE;

	m_TreeCtrl.m_nTreeType = theApp.m_nLastTreeType;	// 树类型
	m_TreeCtrl.m_nTreeID = theApp.m_nLastTreePaneId;
	m_TreeCtrl.m_strBmpFile = theApp.m_strLastBmpFile;
	theApp.m_strLastBmpFile = "";
	if(TREE_ID_NAVIGATER == theApp.m_nLastTreePaneId)
	{
		m_TreeCtrl.m_nTreeType = PGI_FILE;
	}else
	if(TREE_ID_FILE == theApp.m_nLastTreePaneId)
	{
		m_TreeCtrl.m_nTreeType = PGI_FILE;
	}
	m_TreeCtrl.m_nWsNo = m_nWsNo;	// 任务列表号
	m_TreeCtrl.InitTree();	// 初始化图标组和基本菜单
	
	if(TREE_ID_NAVIGATER == theApp.m_nLastTreePaneId)
	{
		// 初始化导航树
		TCHAR szFullPath[MAX_PATH];
		TCHAR szdrive[_MAX_DRIVE];
		TCHAR szdir[_MAX_DIR];
		::GetModuleFileName(NULL, szFullPath, MAX_PATH);
		_splitpath(szFullPath, szdrive, szdir, NULL, NULL);

		CString szPath;
		szPath.Format(_T("%s%s"), szdrive, szdir);
		szPath = szPath.Left(szPath.GetLength() - 1);
		int nPos = szPath.ReverseFind('\\');
		if(nPos >= 0)
		{
			szPath = szPath.Left(nPos+1);
		}
		szPath += _T("conf\\menu\\initnavigater.tcl");

		// 创建解释器
		IInterp* pInterp = NULL;
		if(theApp.m_pIPlatUI)
		{
			pInterp = (IInterp*)(theApp.m_pIPlatUI->CreateVciObject("org.interp.tcl", ""));
		}
		if(pInterp == NULL)
		{
			return;
		}

		// 执行脚本
		// 传递文件名要进行斜杠替换
		szPath.Replace('\\', '/');
		pInterp->RunScriptFile(szPath);

		CString strRes = pInterp->GetResult();

		// 释放解释器
		theApp.m_pIPlatUI->ReleaseVciObject(pInterp, FALSE);
	}else
	if(TREE_ID_FILE == theApp.m_nLastTreePaneId)
	{
		// 初始化文件树
		TCHAR szFullPath[MAX_PATH];
		TCHAR szdrive[_MAX_DRIVE];
		TCHAR szdir[_MAX_DIR];
		::GetModuleFileName(NULL, szFullPath, MAX_PATH);
		_splitpath(szFullPath, szdrive, szdir, NULL, NULL);

		CString szPath;
		szPath.Format(_T("%s%s"), szdrive, szdir);
		szPath = szPath.Left(szPath.GetLength() - 1);
		int nPos = szPath.ReverseFind('\\');
		if(nPos >= 0)
		{
			szPath = szPath.Left(nPos+1);
		}
		szPath += _T("Lib\\plat\\filemng.tcl");

		// 创建解释器
		IInterp* pInterp = NULL;
		if(theApp.m_pIPlatUI)
		{
			pInterp = (IInterp*)(theApp.m_pIPlatUI->CreateVciObject("org.interp.tcl", ""));
		}
		if(pInterp == NULL)
		{
			return;
		}

		// 执行脚本(创建和初始化文件树)
		CString strCmdLine;
		strCmdLine.Format("\"%s\" CreateFileTree", szPath);
		// 传递文件名要进行斜杠替换
		strCmdLine.Replace('\\', '/');
		pInterp->RunScriptFile(strCmdLine);

		//CString strRes = pInterp->GetResult();

		// 释放解释器
		theApp.m_pIPlatUI->ReleaseVciObject(pInterp, FALSE);
	}
}
int CDownloadWithSources::AddSourceURLs(LPCTSTR pszURLs, BOOL bURN)
{
	CString strURLs( pszURLs );
	BOOL bQuote = FALSE;
	
	for ( int nScan = 0 ; nScan < strURLs.GetLength() ; nScan++ )
	{
		if ( strURLs[ nScan ] == '\"' )
		{
			bQuote = ! bQuote;
			strURLs.SetAt( nScan, ' ' );
		}
		else if ( strURLs[ nScan ] == ',' && bQuote )
		{
			strURLs.SetAt( nScan, '`' );
		}
	}
	
	strURLs += ',';
	
    int nCount = 0;
	for ( ; ; )
	{
		int nPos = strURLs.Find( ',' );
		if ( nPos < 0 ) break;
		
		CString strURL	= strURLs.Left( nPos );
		strURLs			= strURLs.Mid( nPos + 1 );
		strURL.TrimLeft();
		
		FILETIME tSeen = { 0, 0 };
		BOOL bSeen = FALSE;
		
		if ( _tcsistr( strURL, _T("://") ) != NULL )
		{
			nPos = strURL.ReverseFind( ' ' );
			
			if ( nPos > 0 )
			{
				CString strTime = strURL.Mid( nPos + 1 );
				strURL = strURL.Left( nPos );
				strURL.TrimRight();
				bSeen = TimeFromString( strTime, &tSeen );
			}
			
			for ( int nScan = 0 ; nScan < strURL.GetLength() ; nScan++ )
			{
				if ( strURL[ nScan ] == '`' ) strURL.SetAt( nScan, ',' );
			}
		}
		else
		{
			nPos = strURL.Find( ':' );
			if ( nPos < 1 ) continue;
			
			int nPort = 0;
			_stscanf( strURL.Mid( nPos + 1 ), _T("%i"), &nPort );
			strURL.Truncate( nPos );
			USES_CONVERSION;
			DWORD nAddress = inet_addr( T2CA( strURL ) );
			strURL.Empty();
			
			if ( ! Network.IsFirewalledAddress( &nAddress, TRUE ) && nPort != 0 && nAddress != INADDR_NONE )
			{
				if ( m_bSHA1 )
				{
					strURL.Format( _T("http://%s:%i/uri-res/N2R?%s"),
						(LPCTSTR)CString( inet_ntoa( *(IN_ADDR*)&nAddress ) ),
						nPort, (LPCTSTR)CSHA::HashToString( &m_pSHA1, TRUE ) );
				}
			}
		}
		
		if ( AddSourceURL( strURL, bURN, bSeen ? &tSeen : NULL ) ) nCount++;
	}
	
	return nCount;
}
Beispiel #24
0
void CBaseConfigPage::OnBnClickedOk()
{
    CPasswordDlg dlg;
	 int iRetrunID=dlg.DoModal();
	 if(iRetrunID==IDCANCEL)
		 return;

	if(!dlg.IsPSWRgiht())
	
	{
       MessageBox("Wrong Password!");
	   return;
	}
	
     CString strDllPathName;
	 CString strDllLossFileName;
	 char szTemp[1024];
	_TCHAR _tKeyName[1000]={0};
	_TCHAR _TSectionName[1000]={0};
	_TCHAR _tKeyValue[1000];
	CString strTemp;
	int iCtrlIDIndex=0;
	CString strChannel;
	CString striLoss;
    
	
	 if(m_listProcessEnable.GetCount()==0)
	 {
      AfxMessageBox("ProcesslistEnable can not be NULL");
	  return;
	 }
	
     
	::GetModuleFileName(NULL, szTemp, _MAX_PATH);

	  
	  strDllPathName.Format("%s",szTemp);
     strDllPathName = strDllPathName.Left(strDllPathName.ReverseFind(_T('\\')));

	strDllPathName=strDllPathName+_T("\\SystemConfig\\SystemSetup.ini");
	
	if(fopen(strDllPathName,"r")==NULL)
	{
        CString strTemp=strDllPathName+_T("  not exist");
		AfxMessageBox(strTemp);
		return ;
	}

	
	GetDlgItemText(IDC_FILESEQPATH,strTemp);
	::WritePrivateProfileString(_T("File Path"),_T("SequencePath"),strTemp,strDllPathName);
    GetDlgItemText(IDC_LOGPATH,strTemp);
   ::WritePrivateProfileString(_T("File Path"),_T("LogPath"),strTemp,strDllPathName);

      GetDlgItemText(IDC_DIAGPORT,strTemp);
	  strTemp=strTemp.Right(strTemp.GetLength()-3);
   ::WritePrivateProfileString(_T("Settings"),_T("PhoneComport"),strTemp,strDllPathName);

      GetDlgItemText(IDC_ATPORT,strTemp);
	  strTemp=strTemp.Right(strTemp.GetLength()-3);
   ::WritePrivateProfileString(_T("Settings"),_T("ATComport"),strTemp,strDllPathName);

    GetDlgItemText(IDC_LOOPCOUNT,strTemp);
	 
   ::WritePrivateProfileString(_T("Settings"),_T("LoopCount"),strTemp,strDllPathName);

    GetDlgItemText(IDC_WAITCOM,strTemp);
	strTemp=strTemp.Left(strTemp.GetLength()-2);
   ::WritePrivateProfileString(_T("Settings"),_T("PhoneOpenPortRetryTime"),strTemp,strDllPathName);

      GetDlgItemText(IDC_TESTSET,strTemp);
   
   ::WritePrivateProfileString(_T("Settings"),_T("TesterDeviceCommon"),strTemp,strDllPathName);

    GetDlgItemText(IDC_TESTSET1,strTemp);
   
   ::WritePrivateProfileString(_T("Settings"),_T("TesterDevice1"),strTemp,strDllPathName);

      GetDlgItemText(IDC_PLY,strTemp);
   
   ::WritePrivateProfileString(_T("Settings"),_T("PowerSupplyCommon"),strTemp,strDllPathName);

    GetDlgItemText(IDC_PLY1,strTemp);
   
   ::WritePrivateProfileString(_T("Settings"),_T("PowerSupply1"),strTemp,strDllPathName);


      GetDlgItemText(IDC_FREQMEAS,strTemp);
   
   ::WritePrivateProfileString(_T("Settings"),_T("FreqMeasDevice"),strTemp,strDllPathName);

    GetDlgItemText(IDC_MULMEAS,strTemp);
   
   ::WritePrivateProfileString(_T("Settings"),_T("MulMeasDevice"),strTemp,strDllPathName);


      GetDlgItemText(IDC_GPIBADDR,strTemp);
   
    ::GetPrivateProfileString(_T("Settings"),_T("Device_Addr"),NULL,_tKeyValue,sizeof(_tKeyValue),strDllPathName);
    CString str=_tKeyValue;  
	int iIndex=str.Find("::");
	CString str1=str.Left(iIndex+2);
	int iIndex2=str.Find("::",iIndex+1);
	CString str2=NULL;
	
	if (iIndex2>-1)
	{
		iIndex=str.GetLength() - str.Find("::",iIndex+1);
		str2=str.Right(iIndex);
	}

	
    str=str1+strTemp+str2;
   ::WritePrivateProfileString(_T("Settings"),_T("Device_Addr"),str,strDllPathName);

     GetDlgItemText(IDC_GPIBADDR1,strTemp);
   
    ::GetPrivateProfileString(_T("Settings"),_T("Device_Addr1"),NULL,_tKeyValue,sizeof(_tKeyValue),strDllPathName);
    str=_tKeyValue;   
	iIndex=str.Find("::");
	str=str.Left(iIndex+2);
    str+=strTemp;
   ::WritePrivateProfileString(_T("Settings"),_T("Device_Addr1"),str,strDllPathName);

      GetDlgItemText(IDC_GPIBADDRPLY,strTemp);
   
    ::GetPrivateProfileString(_T("Settings"),_T("Device_AddrPly"),NULL,_tKeyValue,sizeof(_tKeyValue),strDllPathName);
    str=_tKeyValue;   
	iIndex=str.Find("::");
	str=str.Left(iIndex+2);
    str+=strTemp;
   ::WritePrivateProfileString(_T("Settings"),_T("Device_AddrPly"),str,strDllPathName);

     GetDlgItemText(IDC_GPIBADDRPLY1,strTemp);
   
    ::GetPrivateProfileString(_T("Settings"),_T("Device_AddrPly1"),NULL,_tKeyValue,sizeof(_tKeyValue),strDllPathName);
    str=_tKeyValue;   
	iIndex=str.Find("::");
	str=str.Left(iIndex+2);
    str+=strTemp;
   ::WritePrivateProfileString(_T("Settings"),_T("Device_AddrPly1"),str,strDllPathName);


     GetDlgItemText(IDC_FREQADDR,strTemp);
   
    ::GetPrivateProfileString(_T("Settings"),_T("FreqMeasAddr"),NULL,_tKeyValue,sizeof(_tKeyValue),strDllPathName);
     str=_tKeyValue;   
    iIndex=str.Find("::");
	str=str.Left(iIndex+2);
    str+=strTemp;
   ::WritePrivateProfileString(_T("Settings"),_T("FreqMeasAddr"),str,strDllPathName);

    GetDlgItemText(IDC_MULMEASADDR,strTemp);
   
    ::GetPrivateProfileString(_T("Settings"),_T("MulMeasAddr"),NULL,_tKeyValue,sizeof(_tKeyValue),strDllPathName);
    str=_tKeyValue;   
	 iIndex=str.Find("::");
	str=str.Left(iIndex+2);
    str+=strTemp;
   ::WritePrivateProfileString(_T("Settings"),_T("MulMeasAddr"),str,strDllPathName);


     GetDlgItemText(IDC_PLYPORT,strTemp);
   
   ::WritePrivateProfileString(_T("Settings"),_T("PowerSupplyPort"),strTemp,strDllPathName);

      GetDlgItemText(IDC_PLYPORT1,strTemp);
   
   ::WritePrivateProfileString(_T("Settings"),_T("PowerSupply1Port"),strTemp,strDllPathName);



    
   int iCheck=((CButton*)GetDlgItem(IDC_SFCTRL))->GetCheck();
   ::WritePrivateProfileString(_T("Settings"),_T("IsDoSF"),CStr::IntToStr(iCheck),strDllPathName);

      iCheck=((CButton*)GetDlgItem(IDC_DB))->GetCheck();
   ::WritePrivateProfileString(_T("Settings"),_T("IsDoDB"),CStr::IntToStr(iCheck),strDllPathName);
    
   iCheck=((CButton*)GetDlgItem(IDC_STOPFAIL))->GetCheck();

   ::WritePrivateProfileString(_T("Settings"),_T("StopWhenFail"),CStr::IntToStr(iCheck),strDllPathName);

    iCheck=((CButton*)GetDlgItem(IDC_RUNSN))->GetCheck();

   ::WritePrivateProfileString(_T("Settings"),_T("RunAfterSN"),CStr::IntToStr(iCheck),strDllPathName);

   
   
       
		  theApp.m_vProcessListEnable.clear();
		  for(int i=0;i<m_listProcessEnable.GetCount();++i)
		  {
			  m_listProcessEnable.GetText(i,strTemp);
			  theApp.m_vProcessListEnable.push_back(strTemp);
		  }
     if(m_bChangeProcess)
     theApp.UpdateXMLProcessList();

	 theApp.ParseSystemIni();
	 theApp.MainPageLoadIniUpdateUI();

	 LRESULT lr;
	((CTabCtrl*)GetParent())->SetCurSel(0);
	 ((CSimRFDlg*)AfxGetMainWnd())->OnTcnSelchangeTab4(0,&lr);
     
}
Beispiel #25
0
BOOL CEditBar::PreTranslateMessage(MSG* pMsg) 
{
    CWnd* pWnd;
    CEdit* pEdit;
	if ( pMsg->message == WM_KEYDOWN ) {
        if ( ((CMainFrame*)AfxGetMainWnd())->GetActiveView()->PreTranslateMessage(pMsg) )
            return TRUE;
        switch ( pMsg->wParam ) {
			case VK_RETURN:
			{
				tokenSetup=0;
	 	        if(GetKeyState(VK_SHIFT)&0x1000)  {tokenSetup = 2;}
	 	        if(GetKeyState(VK_CONTROL)&0x1000){tokenSetup = 1;}
     
	            pWnd = ((CMainFrame*)AfxGetMainWnd())->GetActiveView();
		        if ( pWnd ) 
			        pWnd->PostMessage(WM_USER+100 , 0 , 0 );
	            return TRUE;
			}
        case VK_TAB:
            {
                // Check we are in extending mode 
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                if ( m_bExtending ) {
                    // substitute word by new value
                    if ( !m_posCurPos ) 
                        m_posCurPos= m_lstTabWords.GetHeadPosition ();

                    CString strWord = m_lstTabWords.GetNext(m_posCurPos);
                    CString str = m_strStartLine;
                    str += strWord;
                    str+= m_strEndLine;
                    m_bExtendingChange = TRUE;
                    pEdit->SetWindowText (str);
                    pEdit->SetSel (m_strStartLine.GetLength () + strWord.GetLength (), 
                            m_strStartLine.GetLength () + strWord.GetLength ());
                    m_bExtendingChange = FALSE;
                    return TRUE;
                }
                
                // ok, get current line, word etc 
                CString strText;
                pEdit->GetWindowText (strText);

                if ( !strText.GetLength () ) 
                    return TRUE;

                int start, end;
                pEdit->GetSel (start, end);

                if ( end <= 0  || strText[end-1] == ' ') 
                    return TRUE;

                m_strEndLine = strText.Right(strText.GetLength() - end);

                strText = strText.Left(end);

                int cpos = strText.ReverseFind(' ');

                CString strWord;
                if ( cpos < 0 ) {
                    strWord =  strText;
                    m_strStartLine.Empty ();
                } else {
                    strWord = strText.Right(strText.GetLength () - cpos-1);
                    m_strStartLine = strText.Left (cpos +1);
                }
                m_lstTabWords.RemoveAll ();
                // now find all words same as this one 
                CSmcDoc* pDoc = (CSmcDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument ();
                if ( !pDoc ) 
                    return TRUE;

                m_lstTabWords.AddHead(strWord );
                POSITION pos = pDoc->m_lstTabWords.GetHeadPosition ();
                while ( pos ) {
                    CString str = pDoc->m_lstTabWords.GetNext(pos);
                    if ( !strnicmp(str, strWord, strWord.GetLength()) ) {
                        m_lstTabWords.AddTail (str);
                    }
                }

                if ( m_lstTabWords.GetCount () < 2 ) {
                    m_lstTabWords.RemoveAll ();
                    return TRUE;
                }
                m_bExtending = TRUE;
                m_posCurPos = m_lstTabWords.GetHeadPosition();
                m_lstTabWords.GetNext (m_posCurPos);
                strWord = m_lstTabWords.GetNext (m_posCurPos);
                strText = m_strStartLine + strWord + m_strEndLine;
                m_bExtendingChange = TRUE;
                pEdit ->SetWindowText (strText);
                int selpos = m_strStartLine.GetLength () + strWord.GetLength ();
                pEdit->SetSel (selpos, selpos);
                m_bExtendingChange = FALSE;
                return TRUE;

            }
            break;
        case VK_UP:
            if ( GetKeyState(VK_CONTROL) >= 0 ) {
                PrevLine();
                return TRUE;
            } else 
                return FALSE;
        case VK_DOWN:
            if ( GetKeyState(VK_CONTROL) >= 0 ) {
                NextLine();
                return TRUE;
            } else 
                return FALSE;
        case 'C':
            if ( GetKeyState(VK_CONTROL)&0x1000){
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Copy();
                return TRUE;
            }
            break;
		case VK_DELETE:
            if ( GetKeyState(VK_SHIFT)&0x1000){
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Cut();
                return TRUE;
            }
            break;
        case 'X':
            if ( GetKeyState(VK_CONTROL)&0x1000){
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Cut();
                return TRUE;
            }
            break;
		case VK_INSERT:
            if ( GetKeyState(VK_CONTROL)&0x1000){
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Copy();
                return TRUE;
            }
            if ( GetKeyState(VK_SHIFT)&0x1000){
                /*pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Paste();*/
                DoPaste();
                return TRUE;
            }
            break;
        case 'V':
            if ( GetKeyState(VK_CONTROL)&0x1000){
                /*pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Paste();*/
                DoPaste();
                return TRUE;
            }
            break;
        default:
            break;
        };
    }
	if ( pMsg->message == WM_SYSKEYDOWN ) {
        if ( ((CMainFrame*)AfxGetMainWnd())->GetActiveView()->PreTranslateMessage(pMsg) )
            return TRUE;

    }
    
	return CDialogBar::PreTranslateMessage(pMsg);
}
int CContextMenuHandler::RunConsole(LPCTSTR sQueriedPath, bool post, LPCTSTR sQueriedTab)
{
	// We cannot run without path
	if (!sQueriedPath)
		return E_FAIL;

	// is path folder or file?
	CString queriedPath = sQueriedPath; // vds: poasted command

	CString	sCheckedPath = sQueriedPath;
	CString sCheckedFilePath = L""; // vds: posted command

	DWORD iFA = GetFileAttributes(sQueriedPath);
	if (iFA == 0xFFFFFFFF) {
		f_log("Cannot get path attributes - assume it is folder");
	}
	else if(!(iFA & FILE_ATTRIBUTE_DIRECTORY)) {
		// It is file - trim it
		int	dir_index = queriedPath.ReverseFind(_T('\\'));  // vds: posted command
		if (dir_index == -1) {
			// Hmm, there is no folder separator so path is relative to current dir, get it as path
			sCheckedPath = _T(".");
		}
		else {
			sCheckedPath = queriedPath.Left(dir_index);  // vds: posted command
			sCheckedFilePath = queriedPath.Mid(dir_index + 1); // vds: posted command
		}
	}

	// Construct command line
	CString	sCmdLine = _T("\"");

	// Construct executable name (quoted to avoid problems with spaces in path)
	sCmdLine += sExePath;
	sCmdLine += szExeName;
	sCmdLine += _T("\" ");

	// Construct parameters
	if (sQueriedTab && (_tcslen(sQueriedTab) > 0)) {
		sCmdLine += _T("-t ");
//		sCmdLine += _T("-t \"");
		sCmdLine += sQueriedTab;
		sCmdLine += _T(" ");
//		sCmdLine += _T("\" ");
	}

	sCmdLine += _T("-d \"");
	sCmdLine += sCheckedPath;
	sCmdLine += _T("\"");

	// vds: posted command >>
	if (post && sCheckedFilePath != "") {
		sCmdLine += _T(" -p \"");
		sCmdLine += sCheckedFilePath;
		sCmdLine += _T("\"");
	}
	// vds: posted command <<

#ifdef DEBUG_TO_LOG_FILES
	char	tbuf[MAX_PATH];
	sprintf_s(tbuf,MAX_PATH,__FUNCTION__ ": cmd=%S",sCmdLine.GetString());
	f_log(tbuf);
#endif

	// Run process
	STARTUPINFO	si;
	PROCESS_INFORMATION	pi;
	memset(&si,0,sizeof(STARTUPINFO));
	si.cb = sizeof(STARTUPINFO);

	if (CreateProcess(NULL, sCmdLine.GetBuffer(), NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi)) {
		// Success
		// Close handles
		CloseHandle(pi.hThread);
		CloseHandle(pi.hProcess);
	}
	else {
		f_log("Cannot start console process");
	}

	return S_OK;
}
Beispiel #27
0
void SplitFilename(CString fileName, CString* filePath, CString* appName) {
    int lastSep = fileName.ReverseFind('/');
    *filePath = fileName.Mid(0, lastSep);
    int dotPy = fileName.Find(".py");
    *appName = fileName.Mid(lastSep+1, dotPy-lastSep-1);
}
Beispiel #28
0
int CGitIgnoreItem::FetchIgnoreList(const CString &projectroot, const CString &file)
{
	CAutoWriteLock lock(&this->m_SharedMutex);

	if (this->m_pExcludeList)
	{
		free(m_pExcludeList);
		m_pExcludeList=NULL;
	}

	this->m_BaseDir.Empty();
	if (projectroot.GetLength() < file.GetLength())
	{
		CString base = file.Mid(projectroot.GetLength() + 1);
		base.Replace(_T('\\'), _T('/'));
		if (base != _T(".git/info/exclude"))
		{
			int start = base.ReverseFind(_T('/'));
			if(start >= 0)
			{
				base = base.Left(start);
				this->m_BaseDir = CUnicodeUtils::GetMulti(base,CP_ACP) ;
			}
		}
	}
	{

		if(g_Git.GetFileModifyTime(file, &m_LastModifyTime))
			return -1;

		if(git_create_exclude_list(&this->m_pExcludeList))
			return -1;


		CAutoFile hfile = CreateFile(file,
			GENERIC_READ,
			FILE_SHARE_READ|FILE_SHARE_DELETE|FILE_SHARE_WRITE,
			NULL,
			OPEN_EXISTING,
			FILE_ATTRIBUTE_NORMAL,
			NULL);


		if (!hfile)
			return -1 ;

		DWORD size=0,filesize=0;

		filesize=GetFileSize(hfile, NULL);

		if(filesize == INVALID_FILE_SIZE)
			return -1;

		BYTE *buffer = new BYTE[filesize + 1];

		if(buffer == NULL)
			return -1;

		if(! ReadFile(hfile, buffer,filesize,&size,NULL))
			return GetLastError();

		BYTE *p = buffer;
		for (int i = 0; i < size; i++)
		{
			if (buffer[i] == '\n' || buffer[i] == '\r' || i == (size - 1))
			{
				if (buffer[i] == '\n' || buffer[i] == '\r')
					buffer[i] = 0;
				if (i == size - 1)
					buffer[size] = 0;

				if(p[0] != '#' && p[0] != 0)
					git_add_exclude((const char*)p,
										this->m_BaseDir.GetBuffer(),
										m_BaseDir.GetLength(),
										this->m_pExcludeList);

				p=buffer+i+1;
			}
		}
		/* Can't free buffer, exluced list will use this buffer*/
		//delete buffer;
		//buffer = NULL;
	}
	return 0;
}
Beispiel #29
0
int CGitIgnoreList::CheckIgnore(const CString &path,const CString &projectroot)
{
	__int64 time = 0;
	bool dir = 0;
	CString temp = projectroot + _T("\\") + path;
	temp.Replace(_T('/'), _T('\\'));

	CStringA patha;

	patha = CUnicodeUtils::GetMulti(path, CP_ACP) ;
	patha.Replace('\\', '/');

	if(g_Git.GetFileModifyTime(temp, &time, &dir))
		return -1;

	int type = 0;
	if (dir)
		type = DT_DIR;
	else
		type = DT_REG;

	while (!temp.IsEmpty())
	{
		int x;
		x = temp.ReverseFind(_T('\\'));
		if(x < 0)
			x=0;
		temp=temp.Left(x);

		temp += _T("\\.gitignore");

		char *base;

		patha.Replace('\\', '/');
		int pos = patha.ReverseFind('/');
		base = pos >= 0 ? patha.GetBuffer() + pos + 1 : patha.GetBuffer();

		CAutoReadLock lock(&this->m_SharedMutex);

		if(this->m_Map.find(temp) != m_Map.end())
		{
			int ret=-1;

			if(m_Map[temp].m_pExcludeList)
				ret = git_check_excluded_1( patha, patha.GetLength(), base, &type, m_Map[temp].m_pExcludeList);

			if(ret == 1)
				return 1;
			if(ret == 0)
				return 0;
		}

		temp = temp.Left(temp.GetLength()-11);
		temp +=_T("\\.git\\info\\exclude");

		if(this->m_Map.find(temp) != m_Map.end())
		{
			int ret = -1;

			if(m_Map[temp].m_pExcludeList)
				ret = git_check_excluded_1(patha, patha.GetLength(), base, &type, m_Map[temp].m_pExcludeList);

			if(ret == 1)
				return 1;
			if(ret == 0)
				return 0;

			return -1;
		}
		temp = temp.Left(temp.GetLength() - 18);
	}

	return -1;
}
Beispiel #30
0
void CBCGPFileDialog::OnInitDone()
{
	const int iBorderWidth = 20;
	const int iBorderHeight = 40;

	CWnd* pFD = GetParent();
	ASSERT (pFD != NULL);

	CRect rectClient;
	pFD->GetClientRect (rectClient);

	int nNewDlgWidth = rectClient.Width () + iBorderWidth * 2 + m_iExtraWidth;

	if (m_pBmpLogo != NULL)
	{
		BITMAP bmp;
		m_pBmpLogo->GetBitmap (&bmp);

		m_rectLogo = CRect (CPoint (max (0, (nNewDlgWidth - bmp.bmWidth) / 2), 8),
							CSize (bmp.bmWidth, bmp.bmHeight));
		m_iLogoAreaHeight = bmp.bmHeight + 20;
	}

	//---------------------------
	// Adjust parent window size:
	//---------------------------
	pFD->ModifyStyle (WS_THICKFRAME, WS_DLGFRAME | WS_BORDER);
	pFD->ModifyStyleEx (WS_EX_WINDOWEDGE, 0);
	pFD->SetWindowPos (NULL, -1, -1, nNewDlgWidth,
					rectClient.Height () + iBorderHeight * 2 + m_iLogoAreaHeight + m_iExtraHeight,
					SWP_NOMOVE | SWP_NOZORDER  | SWP_NOACTIVATE);

	//-------------------
	// Move all controls:
	//-------------------
	CWnd* pWndChild = pFD->GetWindow (GW_CHILD);
	while (pWndChild != NULL)
	{
		CRect rectCtl;
		pWndChild->GetClientRect (rectCtl);
		pWndChild->MapWindowPoints (pFD, rectCtl);
		pWndChild->SetWindowPos (NULL, 
			rectCtl.left + iBorderWidth, 
			rectCtl.top + iBorderHeight + m_iLogoAreaHeight,
			rectCtl.Width (), rectCtl.Height (), 
			SWP_NOZORDER | SWP_NOACTIVATE);

		pWndChild = pWndChild->GetNextWindow ();
	}

	//------------------------------------------
	// Create new and recent file list controls:
	//------------------------------------------
	CRect rectList (0, 0, 0, 0);
	m_wndNewList.Create (WS_VISIBLE | WS_BORDER | WS_TABSTOP | WS_CHILD | LVS_ICON | LVS_AUTOARRANGE | LVS_SINGLESEL, 
							rectList, pFD, iNewListCtrlId);
	m_wndNewList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	if (m_pImagesNew != NULL)
	{
		m_wndNewList.SetImageList (m_pImagesNew, LVSIL_NORMAL);
	}

	int i = 0;
	for (POSITION pos = m_lstNewItems.GetHeadPosition (); pos != NULL; i ++)
	{
		CNewItemInfo* pInfo = (CNewItemInfo*) m_lstNewItems.GetNext (pos);
		ASSERT_VALID (pInfo);

		m_wndNewList.InsertItem (i, pInfo->m_strName, pInfo->m_iIconIndex);
	}

	m_wndRecentList.Create (WS_TABSTOP | WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT, 
							rectList, pFD, iRecentListCtrlId);
	m_wndRecentList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	m_ImagesRecent.Create (	globalData.m_sizeSmallIcon.cx,
							globalData.m_sizeSmallIcon.cy,
							ILC_COLOR, 0, 10);
	m_wndRecentList.SetImageList (&m_ImagesRecent, LVSIL_SMALL);

	{
		CBCGPLocalResource locaRes;

		CString strFile;
		strFile.LoadString (IDS_BCGBARRES_FILE);
		m_wndRecentList.InsertColumn (0, strFile, LVCFMT_LEFT, 100);

		CString strFolder;
		strFolder.LoadString (IDS_BCGBARRES_FOLDER);
		m_wndRecentList.InsertColumn (1, strFolder);
	}

	CRecentFileList* pMRUFiles = 
		((CBCGApp*) AfxGetApp ())->m_pRecentFileList;

	if (pMRUFiles != NULL)
	{
		TCHAR szCurDir [_MAX_PATH + 1];
		::GetCurrentDirectory (_MAX_PATH, szCurDir);

		int nCurDir = lstrlen (szCurDir);
		ASSERT (nCurDir >= 0);

		szCurDir [nCurDir] = _T('\\');
		szCurDir [++ nCurDir] = _T('\0');

		//---------------
		// Add MRU files:
		//---------------
		int iNumOfFiles = 0;	// Actual added to menu
		for (int i = 0; i < pMRUFiles->GetSize (); i ++)
		{
			CString strFile = (*pMRUFiles) [i];
			if (!strFile.IsEmpty ())
			{
				CString strPath;
				CString strName;
				int iImage = -1;

				int iIndex = strFile.ReverseFind (_T('\\'));
				if (iIndex != -1)
				{
					strPath = strFile.Left (iIndex);
					strName = strFile.Mid (iIndex + 1);
				}
				else
				{
					strName = strFile;
				}

				SHFILEINFO  sfi;
				HIMAGELIST himlSmall = (HIMAGELIST) SHGetFileInfo (strFile,
                                       0,
                                       &sfi, 
                                       sizeof(SHFILEINFO), 
                                       SHGFI_SYSICONINDEX | SHGFI_SMALLICON);

				if (himlSmall != NULL)
				{
					CImageList* pImages = CImageList::FromHandle (himlSmall);
					ASSERT (pImages != NULL);

					HICON hIcon = pImages->ExtractIcon (sfi.iIcon);
					iImage = m_ImagesRecent.Add (hIcon);
					if (hIcon != NULL)
					{
						::DestroyIcon (hIcon);
					}
				}

				iIndex = m_wndRecentList.InsertItem (iNumOfFiles ++, strName, iImage);
				m_wndRecentList.SetItemText (iIndex, 1, strPath);

				int iPathWidth = m_wndRecentList.GetStringWidth (strPath) + 20;
				if (iPathWidth > m_wndRecentList.GetColumnWidth (1))
				{
					m_wndRecentList.SetColumnWidth (1, iPathWidth);
				}
			}
		}
	}

	//---------------------
	// Create tabs control:
	//---------------------
	CRect rectTabs;
	pFD->GetClientRect (rectTabs);
	rectTabs.DeflateRect (4, 4);
	rectTabs.top += m_iLogoAreaHeight;

	m_wndTab.Create (CBCGPTabWnd::STYLE_3D, rectTabs, pFD, iTabCtrlId, 
		CBCGPTabWnd::LOCATION_TOP);
	m_wndTab.m_pParent = this;
	m_wndTab.SetActiveTabBoldFont ();

	m_wndTab.SetFont (GetFont ());
	m_wndTab.SetOwner (this);

	m_wndDummy.Create (_T(""), WS_CHILD, CRect (0, 0, 0, 0), this);

	{
		CBCGPLocalResource locaRes;
		CString strTab;

		if (m_bNewPage)
		{
			m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_NEW_FILE, (UINT)-1, FALSE);
		}

		m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_EXISTING, (UINT)-1, FALSE);
		m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_RECENT, (UINT)-1, FALSE);
	}

	pFD->CenterWindow ();
	pFD->SetWindowText (m_strCaption);

	//------------------
	// Set dilaog icons:
	//------------------
	if (m_hIconSmall != NULL)
	{
		pFD->SetIcon (m_hIconSmall, FALSE);
	}

	if (m_hIconBig != NULL)
	{
		pFD->SetIcon (m_hIconBig, TRUE);
	}

	//--------------------------
	// Setup parent window proc:
	//--------------------------
	m_wndProc = (WNDPROC)SetWindowLongPtr(pFD->m_hWnd, GWLP_WNDPROC, 
		(LONG_PTR) CBCGPFileDialog::WindowProcNew);
}