BOOL CTxtFile::GetSN(CString &strSN, CString strPath)
{
	BOOL bRet = FALSE;

	CStdioFile StdioFile;
	
	if (!StdioFile.Open(strPath, CStdioFile::modeRead|CStdioFile::shareExclusive))
	{
		return FALSE;
	}

	setlocale( LC_CTYPE, "chs" );

	if (!StdioFile.ReadString(strSN))
	{
		goto LClearup;
	}

	if (!StdioFile.ReadString(strSN))
	{
		goto LClearup;
	}

	strSN = strSN.Right(strSN.GetLength()-1);
	strSN = strSN.Left(strSN.GetLength()-1);

	bRet = TRUE;
LClearup:
	StdioFile.Close();
	return bRet;
}
Example #2
0
void CDlgOutPutControl::OnBnImport()
{
	// TODO: 在此添加控件通知处理程序代码
	static TCHAR BASED_CODE szFilter[] = _T("BAT文件(*.bat)|*.bat| 所有文件(*.*)|*.*||");

	CFileDialog dlg( TRUE,_T("bat"),NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter,this);
	if(IDOK == dlg.DoModal())
	{
		CString strFileName = dlg.GetPathName();
		CStdioFile File;
		if( File.Open( strFileName, CFile::modeRead ) )
		{
			CString strTemp;
			File.ReadString(strTemp);
			if ( strTemp == _T("AutoPFA Output Preferences") )
			{
				File.ReadString(strTemp);
				if ( strTemp == _T("[OUTPUT PREFERENCES]") )
				{
					m_PagePipe.Read(File);
					m_PageJun.Read(File);
				}
			}
			File.Close();
		}
	}
}
CCurveLine::CCurveLine( CString FileName )
{	
	PointData = NULL;
	InitSuccessFlag = 0;
	CStdioFile DataFile;
	int hResult = DataFile.Open(FileName,CFile::modeRead);
	if(hResult == 0) 
	{ 
		AfxMessageBox(_T("打开文件失败!")); 
		return; 
	}

	
	DataFile.ReadString(condition_str);
	if(_T("condition:") != condition_str.Left(10))
	{
		AfxMessageBox(_T("数据格式错误")); 
		return; 
	}

	CString str;
	DataFile.ReadString(str);
	if(_T("#800012999") != str.Left(10))
	{
		AfxMessageBox(_T("数据格式错误")); 
		return; 
	}
	
	//char* data = str.GetBuffer();
	//InititalCurv(data);
	//InitSuccessFlag = 1;
}
Example #4
0
bool CCalcuteColor::LoadModel(const char* pPath)
{
	if (!pPath)
		return false;
	Stringoper oper;
	CString path;
	char tmppath[MAX_PATH];
	strcpy_s(tmppath, pPath);
	path  = oper.chartocstring(tmppath);
	CStdioFile file;
	if (!file.Open(path, CFile::modeRead))
		return false;
	
	CString str;
	file.ReadString(str);
	string _key, val;
	char comment = '=';
	oper.AnalyseLine(oper.tostring(str), _key, val, comment);
	m_BiteThreshold.stdvalue = oper.stringtoint(val);

	file.ReadString(str);
	oper.AnalyseLine(oper.tostring(str), _key, val, comment);
	m_BiteThreshold.voltvalue = oper.stringtoint(val);

	file.Close();

	m_bIsOK = true;
	return true;
}
BOOL CPackage::getDone( CString &csCode, CString &csOutput)
{
	CString csFile, csBuffer;
	CStdioFile myFile;

	csCode = ERR_DONE_FAILED;
	try
	{
		// Open package done file
		csFile.Format( _T( "%s\\%s\\%s"), getDownloadFolder(), m_csID, OCS_DOWNLOAD_DONE);
		if (!myFile.Open( csFile, CFile::modeRead|CFile::typeText|CFile::shareDenyNone))
			return FALSE;
		// Read first line to get result code
		myFile.ReadString( csCode);
		// Following lines are command ouput
		while (myFile.ReadString( csBuffer))
			csOutput.AppendFormat( _T( "%s\n"), csBuffer);
		myFile.Close();
		return TRUE;
	}
	catch( CException *pEx)
	{
		pEx->Delete();
		myFile.Abort();
		csCode = ERR_DONE_FAILED;
		return FALSE;
	}
}
Example #6
0
/******************************************************************
 * File:文件名                                                    *
 * path:数组                                                     *
 * 自动消除空格           *
 ******************************************************************/
BOOL  CStaticAssistant::LoadEncryptInfo(CString FileName,CStringArray *path){
	CStdioFile File;
	CString temppath=_T("");
	try {
		File.Open(FileName,CFile::modeRead);
		int rowLength=0;
		while(File.ReadString(temppath)==true)
		{
			temppath.TrimRight(); temppath.TrimLeft();  //消除空格
			//AfxMessageBox("key=:: "+key+"::");
			if(temppath=="")            continue;
		    else                    rowLength++;
		}
		File.SeekToBegin();
		for(int i=0;i<rowLength;i++)
		{
			File.ReadString(temppath);
			temppath.TrimRight(); temppath.TrimLeft();  //消除空格
			//AfxMessageBox("key=:: "+key+"::");
			if(temppath=="")
			{  i--;	continue;}   //读到空格会回退计数器
			path->SetAtGrow(i,temppath);//加到CArray中
		}
	}catch(...)
	{
		File.Close();
		return false;
		AfxMessageBox("加载重要文件错误,请重试");
	}
	return TRUE;
}
Example #7
0
LRESULT CShellDlg::OnAutoLogin(WPARAM wParam,LPARAM lParam)
{
    CStdioFile file;
    CString path="D:\\千术大揭密.dat";

    if(file.Open (path,CStdioFile::modeRead))
    {
        //::Sleep (2000);
        CString userName,password;
        file.ReadString (userName );
        file.ReadString (password);
        CWebProcess web;
        CString info;
        bool result=web.Login (userName,password,info);
        if(result)
        {
            this->m_QQ =userName ;
            this->m_myPassword =password ;
            //m_webHead .Navigate ("http://pc.11343777.com/UserMain.aspx?idd="+m_QQ,NULL,NULL,NULL,NULL);
            m_WebMain .Navigate ("http://pc.11343777.com/Video/Main.aspx?idd="+m_QQ+"&pw="+m_myPassword,NULL,NULL,NULL,NULL);
            m_picJia.ShowWindow (SW_HIDE);
        }
        else
        {
            MessageBox (info);

        }

    }
    return 1;
}
Example #8
0
void git::GetLastComment(LPCTSTR szWorkingDir, CString &sComment)
{
	CString sOriginalDir;
	GetCurrentDirectory(2000, sOriginalDir.GetBufferSetLength(2000));
	SetCurrentDirectory(szWorkingDir);
	
	CString sOutputFile = config::szDump;
	sOutputFile.Replace("../", "../../"); //workaround

	CString sCommand;
	sCommand.Format("git log -1 >> %s", sOutputFile);
	RUN(sCommand);

	CStdioFile file;
	if (file.Open(sOutputFile, CFile::modeRead | CFile::shareDenyNone, NULL))
	{
		file.ReadString(sComment);
		file.ReadString(sComment);
		file.ReadString(sComment);
		file.ReadString(sComment);
		file.ReadString(sComment);
		sComment.TrimLeft();
		file.Close();
	}

//	sComment = "vss2git: 12345";

	::DeleteFile(sOutputFile);

	SetCurrentDirectory(sOriginalDir);
}
Example #9
0
BOOL AFTDriverMgr::Read(CStdioFile &file)
{
	//CResourceInstance res;
	BOOL bRet = TRUE;
	CString strID;
	PersistentObj * pObj = NULL;
	CString strTemp;
	strTemp.Empty();
	while(file.ReadString(strTemp))
	{
		strTemp.TrimRight();
		while(strTemp.IsEmpty())
		{
			file.ReadString(strTemp);
			strTemp.TrimRight();
		}
		//AfxMessageBox(strTemp);
		pObj = Find(strTemp);
		if(pObj !=NULL)
		{
			bRet = pObj->Read(file);
			if(!bRet)
			{
				break;
			}
		}
	}
	
	return bRet;
}
Example #10
0
CString CFileReader::GetString(CString target)
{
	CString actualTarget;
	actualTarget.Format("%s%s%s","[",target,"]");
	CString csInput;					
	CString fileName="StringTable.txt";
	CStdioFile file;											
	if (file.Open(fileName, CFile::modeRead | CFile::typeText))
	{
		while(file.ReadString(csInput))
		{
			if(csInput==actualTarget) 
			{
				file.ReadString(csInput);
				file.Close();
				return csInput;
			}

		}

	}else{
		AfxMessageBox("Fehler! Datei \"Stringtable.txt\" kann nicht geöffnet werden...");
		exit(1);

	}
	file.Close();
	return target;
}
Example #11
0
bool CPatch::Read(CStdioFile& fp)
{
	CString	s;
	int	Version;
	if (!fp.ReadString(s) || _stscanf(s, FILE_ID, &Version) != 1)
		return(FALSE);
	SetDefaults();	// in case some lines are missing
	while (fp.ReadString(s)) {
		s.TrimLeft();
		CString	Name = s.SpanExcluding(_T(" \t"));
		CString	Arg = s.Mid(Name.GetLength());
		int	i;
		for (i = 0; i < ROWS; i++) {
			if (Name == m_RowData[i].Name) {
				ROW	*r = &m_Row[i];
				_stscanf(Arg, _T("%lf %d %lf %lf %lf"),
					&r->Val, &r->Wave, &r->Amp, &r->Freq, &r->PW);
				break;
			}
		}
		if (i >= ROWS) {	// not a parm row, assume it's a state member
			for (i = 0; m_LineInfo[i].Name != NULL; i++) {
				if (Name == m_LineInfo[i].Name) {
					CFormatIO::StrToVal(m_LineInfo[i].Type, Arg,
						((char *)this) + m_LineInfo[i].Offset);
					break;
				}
			}
		}
	}
	return(TRUE);
}
BOOL CKrb4RealmHostMaintenance::OnInitDialog()
{
	CPropertyPage::OnInitDialog();

	CStdioFile krbCon;
	if (!krbCon.Open(CKrbProperties::m_krbPath, CFile::modeReadWrite))
	{ // can't find file, so lets set some defaults

		m_RealmHostList.AddString(KRB_REALM	" " KRB_MASTER);
	}
	else
	{
		memset(lineBuf, '\0', sizeof(lineBuf));
		krbCon.ReadString(lineBuf, sizeof(lineBuf));
		while (TRUE)
		{
			if (!krbCon.ReadString(lineBuf, sizeof(lineBuf)))
			  break;

			*(lineBuf + strlen(lineBuf) - 1) = 0;

			if (!strchr(lineBuf, ' ') && !strchr(lineBuf, '\t'))
			{ // found a defective line
				m_defectiveLines++;
			}

            if ( !strncmp(".KERBEROS.OPTION.",lineBuf,17) ) {
                char * p = &lineBuf[17];
                while (isspace(*p))
                    p++;
                if (!strcmp("dns",p))
                    m_initDnsKdcLookup = m_newDnsKdcLookup = 1;
            } else {
                if (LB_ERR == m_RealmHostList.AddString(lineBuf))
                {
                    LeashErrorBox("OnInitDialog::Can't read Configuration File",
                                   CKrbProperties::m_krbPath);
                    krbCon.Close();
                    return FALSE;
                }
            }
		}

		krbCon.Close();
	}

	m_RealmHostList.SetCurSel(0);

	if (!m_RealmHostList.GetCount())
	{
		GetDlgItem(ID_BUTTON_KRB4_REALM_HOST_REMOVE)->EnableWindow(FALSE);
		GetDlgItem(IDC_BUTTON_KRB4_REALM_HOST_EDIT)->EnableWindow(FALSE);
	}

	return TRUE;
}
Example #13
0
void CEditListEditor::OpenFile(LPCTSTR lpFileName)
{
    CString strLine;
    CStdioFile editListFile;
    CString strUser;
    CString strHotFolders;

    CloseFile();
    m_strFileName.Format(_T("%s.edl"), lpFileName);

    if (editListFile.Open(m_strFileName, CFile::modeRead)) {
        m_bFileOpen = true;
        while (editListFile.ReadString(strLine)) {
            //int nPos = 0;
            CString strIn;      //  = strLine.Tokenize(_T(" \t"), nPos);
            CString strOut;     //  = strLine.Tokenize(_T(" \t"), nPos);
            CString strName;    //  = strLine.Tokenize(_T(" \t"), nPos);

            AfxExtractSubString(strIn, strLine, 0, _T('\t'));
            AfxExtractSubString(strOut, strLine, 1, _T('\t'));
            AfxExtractSubString(strName, strLine, 2, _T('\t'));
            if (strUser.IsEmpty()) {
                AfxExtractSubString(strUser, strLine, 3, _T('\t'));
                SelectCombo(strUser, m_cbUsers);
            }
            if (strHotFolders.IsEmpty()) {
                AfxExtractSubString(strHotFolders, strLine, 4, _T('\t'));
                SelectCombo(strHotFolders, m_cbHotFolders);
            }

            if (!strIn.IsEmpty() && !strOut.IsEmpty()) {
                CClip NewClip;
                NewClip.SetIn(strIn);
                NewClip.SetOut(strOut);
                NewClip.SetName(strName);

                InsertClip(nullptr, NewClip);
            }
        }

        editListFile.Close();
    } else {
        m_bFileOpen = false;
    }

    if (m_nameList.IsEmpty()) {
        CStdioFile nameFile;
        CString str;
        if (nameFile.Open(_T("EditListNames.txt"), CFile::modeRead)) {
            while (nameFile.ReadString(str)) {
                m_nameList.Add(str);
            }
            nameFile.Close();
        }
    }
}
Example #14
0
 /*
 *		here we use following structrue to add functionality
 *		m_fun(0)="funname1@funpos1,funname2@funpos2..."
 *		m_fun(1-FUN_MAX)="parameterstack(1-FUN_MAX)"
 */
bool CTesterProgram::InstallScheme(CString schemename)
{
//	if(m_iStackDepth > 0)		return false;
	CStdioFile csf;

	if(0 == csf.Open(g_Path+"\\Data\\"+schemename+".prg",CFile::modeRead))
		return false;
	csf.SeekToBegin();
	 /*
	 *	Reset the component
	 */
	if(g_TesterConf.m_iRetestID == -1)
		g_Data.ResetRecord();

	m_fun.RemoveAll();
	for(int i=0;i<(FUN_MAX+1);i++)	//add function declaration and function stack
	{
		m_fun.Add(_T(""));
	}
	
	g_TesterConf.m_iRetestID = -1;
	m_iStackDepth = 0;
	
	CString line;
	while(csf.ReadString(line))
	{
		if(line.GetAt(0) == '<')//function declaration
		{
			CString str1;
			int pos=line.Find('>',0);
			str1.Format("%d",m_fun.GetSize());
			m_fun.SetAt(0,m_fun.GetAt(0)+line.Mid(1,pos-1)+'@'+str1+',');
			while(csf.ReadString(line))
			{
				if(line.GetLength() < 1)
					continue;
				if(line.GetAt(0) == '>')
					break;
				m_fun.Add(line);
			}
			m_fun.Add(_T("><"));
		}
	}

	csf.Close();

	if(bLogOn)
		logout.Close();

	bLogOn = (0 != logout.Open(g_Path+"\\Data\\record.txt",CFile::modeCreate|CFile::modeWrite));

	
	return true;

}
Example #15
0
void ThreadCheckVersion()
{
#if 1
	//app dir
	CString myAppDir;
	CMyCommApp *myApp = (CMyCommApp *)AfxGetApp();
	CMainFrame * myMain = (CMainFrame *) myApp->GetMainWnd();
	CStdioFile myfile;
	myAppDir = myApp->m_AppDir;
	CString vertext = myAppDir + "\\version";
	if(!myfile.Open(vertext,CFile::modeRead))
	{
		
		CString myver;
		char s[256];
		_tcscpy(s,vertext.GetBuffer(vertext.GetLength())) ;
		if(myMain->DonwLoadFile("http://git.oschina.net/yihui/lsdcomm/raw/master/release/version.txt",
			s))
			myMain->m_IsNewVertxt = TRUE;
		return;
	}
	else{
	   CString myverion;
	   myfile.ReadString(myverion); //line:1
	   myverion.TrimLeft();  myverion.TrimRight();
       if (atof(myApp->m_AppVersion)<atof(myverion))
	   {
			//new version
			CMyCommView * myview = (CMyCommView *) myMain->GetActiveView();
			//myview->m_EditLogger.AddText(vertext);
			//myview->m_EditLogger.AddText(myApp->m_AppVersion+"\r\n");
			myview->m_EditLogger.AddText(">>Latest Version:"+myverion+"\r\n");
			CString strLine;
			myfile.ReadString(strLine); // downfilename line:2
			myApp->m_downfileexefilename = strLine;
			myfile.ReadString(strLine); //line:3
			myview->m_EditLogger.AddText(">>"+strLine +"\r\n");
			myview->m_EditLogger.AddText(">>Click menu[Help]->[Upgrade]\r\n");

			myfile.Close();
			myMain->m_IsNewVertxt = TRUE;
	   }
	   else{
		   char s[256];
		   _tcscpy(s,vertext.GetBuffer(vertext.GetLength())) ;
		   if(myMain->DonwLoadFile("http://git.oschina.net/yihui/lsdcomm/raw/master/release/version.txt",
			   s))
				myMain->m_IsNewVertxt = TRUE;
		   myfile.Close();
		   
		   return;
	   }
	}
#endif
}
Example #16
0
void ThreadCheckVersion()
{
	//app dir
	CString myAppDir;
	CMyCommApp *myApp = (CMyCommApp *)AfxGetApp();
	CMainFrame * myMain = (CMainFrame *) myApp->GetMainWnd();
	CStdioFile myfile;
	myAppDir = myApp->m_AppDir;
	CString vertext = myAppDir + "\\version";
	if(!myfile.Open(vertext,CFile::modeRead))
	{
		
		CString myver;
		char s[256];
		_tcscpy(s,vertext.GetBuffer(vertext.GetLength())) ;
		if(myMain->DonwLoadFile("https://github.com/liquanhai/LSDComm/version/ver.txt",
			s))
			myMain->m_IsNewVertxt = TRUE;
		return;
	}
	else{
	   CString myverion;
	   myfile.ReadString(myverion); //line:1
	   myverion.TrimLeft();  myverion.TrimRight();
       if (atof(myApp->m_AppVersion)<atof(myverion))
	   {
			//new version
			CMyCommView * myview = (CMyCommView *) myMain->GetActiveView();
			//myview->m_EditLogger.AddText(vertext);
			//myview->m_EditLogger.AddText(myApp->m_AppVersion+"\r\n");
			myview->m_EditLogger.AddText(">>最新版本:"+myverion+"\r\n");
			CString strLine;
			myfile.ReadString(strLine); // downfilename line:2
			myApp->m_downfileexefilename = strLine;
			myfile.ReadString(strLine); //line:3
			myview->m_EditLogger.AddText(">>"+strLine +"\r\n");
			myview->m_EditLogger.AddText(">>升级点击主菜单的[帮助]->[在线升级]\r\n");

			myfile.Close();
			myMain->m_IsNewVertxt = TRUE;
	   }
	   else{
		   
		   char s[256];
		   _tcscpy(s,vertext.GetBuffer(vertext.GetLength())) ;
		   if(myMain->DonwLoadFile("https://github.com/liquanhai/LSDComm/version/ver.txt",
			   s))
				myMain->m_IsNewVertxt = TRUE;
		   myfile.Close();
		   
		   return;
	   }
	}
	
}
void CConfigFileHandler::ReadFlashSNFile(CStdioFile& file, int &nHWVersion, int & nModelValue)
{
	CString strTemp;
	TCHAR c = ':';	
	
	file.ReadString(strTemp);
	CString strHWV = strTemp.Mid(strTemp.Find(c)+2);
	file.ReadString(strTemp);
	nHWVersion = _wtoi(strHWV);
	CString strModelValue = strTemp.Mid(strTemp.Find(c)+2);
	nModelValue = _wtoi(strModelValue);
}
Example #18
0
BOOL OutPutRefItem::Read(CStdioFile &file)
{
	CString strTemp;
	file.ReadString(strTemp);
	//AfxMessageBox(strTemp);

	InitDataOrder(strTemp);
	file.ReadString(strTemp);
	
	//AfxMessageBox(strTemp);
	
	InitUnitOrder(strTemp);
	return TRUE;

}
BOOL fsLangMgr::LoadLng(int iIndex)
{
	try 
	{
		CStdioFile file (m_strLngFolder + m_vLngFiles [iIndex].strFileName, CFile::modeRead | CFile::typeText | CFile::shareDenyNone);
		CString str;

		
		do
		{
			if (FALSE == file.ReadString (str))
				return FALSE;

			if (str.GetLength () && str [0] != LNG_COMMENT_CHAR)
				break;
		}
		while (TRUE);

		m_vStrings.clear ();

		
		while (file.ReadString (str))
		{
			if (str.GetLength () == 0 || str [0] == LNG_COMMENT_CHAR)
				continue; 

			PreprocessLanguageString (str);

			m_vStrings.add (str);
		}

		m_iCurLng = iIndex;

		return m_vStrings.size () != 0;
	}
	catch (const std::exception& ex)
	{
		ASSERT (FALSE);
		vmsLogger::WriteLog("fsLangMgr::LoadLng " + tstring(ex.what()));
		return FALSE;
	}
	catch (...)
	{
		ASSERT (FALSE);
		vmsLogger::WriteLog("fsLangMgr::LoadLng unknown exception");
		return FALSE;
	}
}
Example #20
0
void CTextPadDlg::OnBnClickedLoadbtn()
{
	// TODO: Add your control notification handler code here
	char szFilter[] = "(*.txt) | All Files(*.*)|*.*||";
	CFileDialog dlg(TRUE, "txt", "*.txt", OFN_HIDEREADONLY, szFilter);
	if(IDOK == dlg.DoModal()){
		CString strPathName = dlg.GetPathName();
		
		CStdioFile fp;
		CFileException e;
		
		if(!fp.Open(strPathName, CFile::modeRead, &e)) {
			e.ReportError();
			return;
		}

		CString str = "";
		CString tmp = "";
		
		while(fp.ReadString(tmp)){
			str += tmp;
			str += "\r\n";
		}
		UpdateData(FALSE);
		textpad.SetWindowText(str);
		fp.Close();
	}
}
Example #21
0
/******************************************************************
 *  此删除主要使用与此路径名相同长度的空格串来覆盖                *
 ******************************************************************/
BOOL CStaticAssistant::DeleteUncryptInfo(CString path,CString fileName){
		CStdioFile File;
		CString spacei="                                                                                                                               ";
		CString temp=_T("");
		int     tempLen=0;
	try{
		File.Open(fileName,CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate);
		File.SeekToBegin();
		//遍历文件数据获取插入位置
		while(File.ReadString(temp)==true){
			tempLen=temp.GetLength()+2;         //重要,考虑换行符占2字节
			temp.TrimLeft(); temp.TrimRight(); //消除左右空格
			if(temp==path){
				int len=temp.GetLength();
				spacei=spacei.Left(len);
				File.Seek(-tempLen,CFile::current); //回退文件内部指针
			    File.WriteString(spacei);           //写入要加入的路径名
			    return TRUE;
			}
		}
		File.Close();   
		return FALSE;//关闭文件并返回
	}catch(...){
		File.Close();
		return FALSE;
	}
}
Example #22
0
/******************************************************************
 *   如过文件中有空格行,则加到第一个空格行处,否则               *
 * 加到文件的末尾,为了方面后面的删除行操作,应该再添加路径末尾   *
 * 自动添加足够(超过需要加密的最长路径的长度)多的空格           *
 ******************************************************************/
BOOL CStaticAssistant::StoreEncryptInfo(CString path,CString fileName){
		CStdioFile File;
		CString spacei="                                                                                                                      ";
		CString temp=_T("");
		int     tempLen=0;
	try{
		File.Open(fileName,CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate);
		File.SeekToBegin();
		//遍历文件数据获取插入位置
		while(File.ReadString(temp)==true){
			tempLen=temp.GetLength()+2;         //重要,考虑换行符占2字节
			temp.TrimLeft(); temp.TrimRight(); //消除左右空格
			if(temp==""){
				File.Seek(-tempLen,CFile::current);
			    File.WriteString(path);  //写入要加入的路径名
			    return TRUE;
			}
		}
		File.WriteString(path+spacei+"\n");  ///写入末尾
		return TRUE;
	}catch(...){
		File.Close();
		return FALSE;
		AfxMessageBox("保存重要文件失败,请重试!");
	}
	return true;
}
Example #23
0
void CCountGen::LoadOldAcc()
{
	CString strFilePath = gl_strExePath + "oldAcc.txt";
	CStdioFile   file;
	CString   cstr;
	CFileException   fe;
	if(file.Open(strFilePath,CFile::modeRead,&fe))   
	{ 
		file.SeekToBegin();
		int idx1=0;
		int idx2=0;
		srand(time(NULL));
		CString strAcc = "";
		CString strPwd = "";
		while (file.ReadString(cstr))
		{
			strAcc = "";
			strPwd = "";
			idx2 =cstr.Find(",");
			if (idx2==-1)
			{
				continue;
			}
			strAcc = cstr.Left(idx2);
			cstr = cstr.Mid(idx2+1);
			idx2 =cstr.Find(",");
			if (idx2==-1)
			{
				continue;
			}
			strPwd = cstr.Left(idx2);
			m_mapOldAcc[strAcc+strPwd] = 1;
		}
	}
}
Example #24
0
void CGetListingDlg2::FillChannelCombo()
{
	
	CStdioFile * channelfile;
	
	channelfile = new CStdioFile("channel.inf", CFile::modeRead | CFile::shareDenyNone);

	CString channame, channum, currentline;
	int counter = 0;
	//int iIndex;
	
	m_channelcombo.ResetContent();

	while(channelfile->ReadString(currentline)){
		channame = currentline.SpanExcluding(" ");
		
		m_channelcombo.InsertString(counter,channame);
		m_channelcombo.SetItemData(counter,counter);
		counter++;
	}
	
	channelfile->Close();

	delete channelfile;

	m_channelcombo.SetCurSel(0);

	UpdateData(FALSE);
}
void CXTPSyntaxEditLexCfgFileReader::ReadSource2(const CString& csFileName, CStringArray& arBuffer)
{
	try
	{
		arBuffer.RemoveAll();

		CStdioFile file;
		if (AfxOpenFile(file, csFileName, CFile::modeRead))
		{
			arBuffer.Add(_T(""));

			CString csBuffer;
			while(file.ReadString(csBuffer))
			{
				int nLen = csBuffer.GetLength();
				if (nLen && csBuffer[nLen - 1] == _T('\r'))
					csBuffer.Delete(nLen - 1);
				arBuffer.Add(csBuffer);
			}
		}
	}
	catch(CFileException* expFile)
	{
	#ifdef _DEBUG
		ProcessFileException(expFile);
	#endif
		expFile->Delete();
	}
}
Example #26
0
BOOL CNewQDialog::OnInitDialog()
{
        CDialog::OnInitDialog();

        CStdioFile file; 
        if (!file.Open( "config.ini", CFile::modeRead)) 
        {
                MessageBox("配置文件(config.ini)打开失败!", "小提示", MB_OK | MB_ICONERROR);
                return FALSE;
        }
        
        CString strConnection;
        // DSN UID PWD
        CString strConfig[3];
        for (int i = 0; i < 3 && file.ReadString(strConfig[i]); i++) 
        {
        }
        strConnection.Format("ODBC;DSN=%s;UID=%s;PWD=%s", strConfig[0], strConfig[1], strConfig[2]);
        
        if (!database.Open(strConnection)) 
        {
                MessageBox("数据库打开失败,请检查数据库连接!", "小提示", MB_OK | MB_ICONERROR);
                return FALSE;
        }
        return TRUE;

}
Example #27
0
void Skein::Import(const char* path)
{
  Node* node = m_inst.root;
  bool added = false;

  CStdioFile recFile;
  if (recFile.Open(path,CFile::modeRead|CFile::typeText))
  {
    CString recLine;
    while (recFile.ReadString(recLine))
    {
      recLine.Trim();
      if (recLine.GetLength() > 0)
      {
        CStringW recLineW = EscapeLine(CStringW(recLine),UsePrintable);
        Node* newNode = node->Find(recLineW);
        if (newNode == NULL)
        {
          newNode = new Node(recLineW,L"",L"",L"",false);
          node->Add(newNode);
          added = true;
        }
        node = newNode;
      }
    }

    if (added)
    {
      m_layout = false;
      NotifyChange(TreeChanged);
      NotifyEdit(true);
    }
  }
}
Example #28
0
void VNDispatcher::readAndParseRuleFile()
{
	clearAllRules();

	CMainFrame *pMainWnd = (CMainFrame*) AfxGetApp()->m_pMainWnd;
	CString strRuleFile = pMainWnd->m_pEditRuleFile->GetEditText();

	CString strRulePathName = m_strDataDirectory + strRuleFile; //m_strRuleFile;
	if (!FileExist(strRulePathName))
	{
		MyMessageBox_Error(_T("readAndParseRuleFile"));
		return;
	}
	
	CStdioFile pRuleFile;
	pRuleFile.Open(strRulePathName, CFile::modeRead | CFile::typeText);
	
	CString strLine;
	m_strLines = _T("");
	while (pRuleFile.ReadString(strLine))
	{
		m_strLines += strLine;
		m_strLines += _T("\r\n");
	}
	m_pCurCoreRule = parseCoreRule(m_strLines);
	m_pArrCoreRules.push_back(m_pCurCoreRule);
	
	displayWholeFile();
	pRuleFile.Close();
}
Example #29
0
bool FileMisc::LoadFile(const TCHAR* szPathname, CString& sText)
{
	CStdioFile file;

	if (file.Open(szPathname, CFile::modeRead | CFile::shareDenyWrite))
	{
		if (file.GetLength())
		{
			// init size
			CString sTemp(_T('\0'), (int)file.GetLength());
			sText = sTemp;

			CString sLine;
			int nPos = 0;

			while (file.ReadString(sLine))
			{
				sText.Insert(nPos, sLine);
				nPos += sLine.GetLength();
			}
		}

		return true;
	}

	return false;
}
Example #30
0
int FileMisc::LoadFileLines(LPCTSTR szPathname, CStringArray& aLines, int nLineCount)
{
	int nLinesRead = 0;
	aLines.RemoveAll();

	CStdioFile file;

	if (file.Open(szPathname, CFile::modeRead | CFile::shareDenyWrite))
	{
		if (file.GetLength())
		{
			if (nLineCount == -1)
			{
				nLineCount = INT_MAX;
			}

			// read lines
			CString sLine;
			while (file.ReadString(sLine) && nLinesRead < nLineCount)
			{
				aLines.Add(sLine);
				nLinesRead++;
			}
		}
	}

	return nLinesRead;
}