コード例 #1
0
ファイル: AFCFunction.cpp プロジェクト: liuwanbing/liuwanbing
//写错误日志
void  WriteError(TCHAR *pMessage ,int iRoomID,int iSmallRoomID )
{
	try
	{
		char FileName[50];
		TCHAR path[MAX_PATH];
		
        // PengJiLin, 2010-6-7, GetCurrentDirectory()函数全部替代
        //::GetCurrentDirectory (MAX_PATH,path);
        lstrcpy(path, CBcfFile::GetAppPath());

		wsprintf(FileName,"%s\\Error%d-%d.txt\0",path,iRoomID,iSmallRoomID);//GetCurrentProcessId());
		CFile syslog;
		syslog.Open(FileName,CFile::modeNoTruncate| CFile::modeCreate |CFile::modeReadWrite);
		syslog.SeekToEnd();
		syslog.Write(pMessage,strlen(pMessage));

		syslog.SeekToEnd();
		TCHAR nextLine[] = "\r\n";
		syslog.Write(nextLine,strlen(nextLine));

		syslog.Close();
	}
	catch(CException *e)
	{		
	TRACE("%s\n",__FUNCTION__);	//AfxMessageBox("some exception!");
		e->Delete();
		return ; 
	}
}
コード例 #2
0
ファイル: stdafx.cpp プロジェクト: enildne/zest
void RTrace(TCHAR* szFormat, ...)
{
#ifdef MESSAGE_TRACE
	TCHAR szTempBuf[2048] ;
	va_list vlMarker ;

	va_start(vlMarker,szFormat) ;
	StringCchVPrintf(szTempBuf, 2048, szFormat, vlMarker) ;
	va_end(vlMarker) ;

#ifdef LOG_FILE_DEBUG
	USES_CONVERSION;
	char	des[2048];
	CFile logFile;
	int z = (int)wcslen(szTempBuf);

	wcstombs(des, szTempBuf, z);

	des[z - 1] = 0x0d;
	des[z] = 0x0a;

	logFile.Open(L"C:\\Earzone\\EzCam\\EzCamLog.txt", CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate);
	logFile.SeekToEnd();
	logFile.Write(des, z + 1);
	logFile.Close();
#endif		// CODEC DEBUG

	OutputDebugString(szTempBuf) ;
#endif		// MESSAGE_TRACE
}
コード例 #3
0
ファイル: Gif.cpp プロジェクト: lincoln56/robinerp
BOOL WriteToFile(LPCTSTR lpstrFilePathName, LPCTSTR lpstrErrorText)
{
	return true;
	CFile	tempFile;
	if (! tempFile.Open(lpstrFilePathName, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite|CFile::shareDenyWrite|CFile::typeBinary))
	{
		return FALSE;
	}

	tempFile.SeekToEnd();

	char szNewLine[] = "\r\n";
	tempFile.Write(szNewLine, strlen(szNewLine));			//换行	
	
#ifdef UNICODE
	//char	szErrorText[255]= {0};
	//::WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, lpstrErrorText, wcslen(lpstrErrorText), szErrorText, 255, NULL, NULL);
	//tempFile.Write(szErrorText, strlen(szErrorText));
	//tempFile.Write(lpstrErrorText, strlen((char *)lpstrErrorText));
#else
	tempFile.Write(lpstrErrorText, strlen(lpstrErrorText));
#endif

	//写入游戏信息
	tempFile.Close();
	return TRUE;
}
コード例 #4
0
ファイル: MainFrm.cpp プロジェクト: liquanhai/LSDComm
void CMainFrame::OnSendFile() 
{
	// TODO: Add your command handler code here
	CMyCommDoc   *Doc   =  (CMyCommDoc   *)GetActiveDocument();
	if (!Doc->m_ComAction) {
		AfxMessageBox(_T("串口没有打开!"));
		return;
	}
	
	CSendFileByXModem dlg;
	dlg.m_ModemType = 0;
	if (dlg.DoModal()==IDOK)
	{
		//发送文件
		CFile fp;
		if(!(fp.Open((LPCTSTR)dlg.m_SendFileName ,CFile::modeRead))) 
		{
			AfxMessageBox(_T("打开文件出错!"));
			return;
		}
		fp.SeekToEnd();
		unsigned long fplength=fp.GetLength();
		char* fpBuff;
		fpBuff=new char[fplength];
		fp.SeekToBegin();
		if(fp.Read(fpBuff,fplength)<1)
		{
			fp.Close();
			return;
		}
		fp.Close();

		//send
		CMyCommView * myview = (CMyCommView *)GetActiveView();
		myview->m_EditLogger.AddText(_T("发送文件....\r\n"));
		BOOL mySendOk;
        
		switch(dlg.m_ModemType) {
			case 0:  //xModem
				mySendOk = Doc->SendByXmodem(fpBuff,fplength,0);
				break;
			case 1: //yModem
				break;
			case 2: //zModem
				
				break;
			case 3: //1k xmodem 
				
				break;
			default:
				return;
		}

		if(mySendOk)
			myview->m_EditLogger.AddText(_T("完成发送。\r\n"));
		else
			myview->m_EditLogger.AddText(_T("发送失败!!!\n\r"));

	}
}
コード例 #5
0
ファイル: history.cpp プロジェクト: prakash028/newscaster
BOOL Log_App_FileWrite( char *filename, char *txt )
{
	if( CFG->cfgEnableLogs )
	{
		CFile localFile;
		BOOL result;

		result = localFile.Open( filename, CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate );

		if( !result )
		{
			CreateDirectory( "Logs" , NULL );
			result = localFile.Open( filename, CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate );
		}

		if( result && txt )
		{
			long filesize = localFile.GetLength();
			localFile.SeekToEnd();
			localFile.Write( txt, strlen(txt) );
			localFile.Write( "\r\n", 2 );
			localFile.Close();
			if( filesize > 1024*1024 )
			{
				RollLogFile( filename );
			}
			return TRUE;
		}
		else
			return FALSE;
	} else
		OutputDebugString( txt );
	return FALSE;
}
コード例 #6
0
void IniAI(int i)
{
	CFile F;
	F.Open(DL_DIR BAC_CFG_LOC_INIVAL, CFile::modeWrite, NULL);
	F.SeekToEnd();

	Ini_PresentValue_Analog(i, &F);	
	Ini_Description(i, &F);
	Ini_DeviceType(i, &F);
	Ini_Reliability(i, &F);
	Ini_Out_Of_Service(i, &F);
//	Ini_Update_Interval(i, &F);
	Ini_Units(i, &F);
	Ini_Min_Present_Value(i, &F);
	Ini_Max_Present_Value(i, &F);
	Ini_Resolution(i, &F);
	Ini_COV_Increment(i, &F);
	Ini_Time_Delay(i, &F);
//	Ini_Notification_Class(i, &F);
	Ini_High_Limit(i, &F);
	Ini_Low_Limit(i, &F);
	Ini_Deadband(i, &F);
	Ini_Limit_Enable(i, &F);
	Ini_Event_Enable(i, &F);
	Ini_Notify_Type(i, &F);

	F.Close();
}
コード例 #7
0
void CComplSocketClient::DealCache(const CString& msg)
{
	if(msg.IsEmpty() || IsTheSameMsg(msg))return;
	theApp.m_list_caCheMsg.push_back(msg);
#ifdef _DEBUG
	CString str=_T("cache size:");
	str.AppendFormat(_T("%d"),theApp.m_list_caCheMsg.size());
	MyWriteConsole(str);
#endif
	if(theApp.m_list_caCheMsg.size()>=10)
	{
		CFile file;
		if(file.Open(m_caChePath,CFile::modeCreate | CFile::modeNoTruncate |CFile::modeWrite))
		{
			std::list<CString>::const_iterator itera = theApp.m_list_caCheMsg.begin();
			for(itera;itera!=theApp.m_list_caCheMsg.end();itera++)
			{
				file.SeekToEnd();
				CString temp = *itera;
				char tempBuf[MAXRECVBUF] ={0};
				CCommonConvert::CStringToChar(temp,tempBuf);
				file.Write(tempBuf,MAXRECVBUF);
			}
			theApp.m_list_caCheMsg.clear();//清除缓存
			file.Close();
		}
	}
}
コード例 #8
0
void CFirewallOpener::ClearMappingsAtEnd() {
    m_bClearMappings = true;
    CICSRuleInfo mapping, search;

    //Add all mappings to the ICF.dat file
    CFile fICFdat;
    if(fICFdat.Open(GetICFdatFileName(), CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite|CFile::typeBinary)) {
        for(int i = 0; i < m_liAddedRules.GetCount(); i++) {
            mapping = m_liAddedRules.GetAt(i);

            //Search for the item on ICF.dat
            fICFdat.SeekToBegin();
            bool found = false;
            while(!found && ReadFromICFdat(fICFdat, search)) {
                if(search.m_nPortNumber == mapping.m_nPortNumber &&
                        search.m_byProtocol == mapping.m_byProtocol &&
                        search.m_strRuleName == mapping.m_strRuleName)
                {
                    found = true;
                }
            }

            if(!found) {
                fICFdat.SeekToEnd();
                AddToICFdat(fICFdat, mapping);
            }
        }
        fICFdat.Close();
    }
}
コード例 #9
0
ファイル: GameAI.cpp プロジェクト: donilan/study
void CGameAI::writeLog( CString str )
{
	static TCHAR* szFileName = TEXT("运行日志.log");
	const DWORD unicode = 0xFEFF;
	CString fmtStr;
	CTime nowTime = CTime::GetCurrentTime();
	CFile file;
	CFileStatus status;
	BOOL isOk = FALSE;
	if( CFile::GetStatus( szFileName, status ) )
	{
		// Open the file without the Create flag
		//OutputDebugString(TEXT("Write file.\n"));
		isOk = file.Open( szFileName, CFile::modeWrite );
	}
	else
	{
		// Open the file with the Create flag
		//OutputDebugString(TEXT("Create file.\n"));
		isOk = file.Open( szFileName, CFile::modeCreate | CFile::modeWrite );
		if(isOk)
		{
			file.Write(&unicode, 2);
		}
	}
	if(isOk)
	{
		file.SeekToEnd();
		fmtStr.Format(TEXT("%s - %s\r\n"), nowTime.Format("%Y-%m-%d %H:%M:%S"), str);
		file.Write(fmtStr, fmtStr.GetLength()*sizeof(TCHAR));
		file.Close();
	}
	
}
コード例 #10
0
// See ConfigDlg.h for documentation of this method.
BOOL ConfigDlg::ReadBootloaderConfigureArea()
{
    CString filePath;
    m_ctrlImageFile.GetWindowTextW(filePath);
    CFile *cFile = new CFile(filePath.GetBuffer(), CFile::modeReadWrite | CFile::typeBinary);
    filePath.ReleaseBuffer();

    ULONGLONG length = cFile->GetLength();
    if (length < 0x400)
    {
        PrintLog(_T("Warning: File(%s) is smaller than 1K bytes, fill 0xFFs to extend it to 1K bytes."), filePath);
        cFile->SeekToEnd();
        while (length < 0x400)
        {
            cFile->Write("\xFF", 1);
            length++;
        }
        cFile->Flush(); // Flush the 0xFFs to file.
    }

    cFile->Seek(0x3C0, CFile::begin);
    cFile->Read(m_bcaData, 64);

    PrintLog(_T("Read BCA data from image file."));

    delete cFile;

    UpdateDataOfBootloaderConfigureArea(FALSE);

    return TRUE;
}
コード例 #11
0
BOOL KiesBNR::CreateWriteMMSMessageXmlCSVFile(CString dstPath){
	pair<multimap<CString, _MMSMessageXml>::iterator, multimap<CString, _MMSMessageXml>::iterator>iter_mmsmessagexml;
	multimap<CString, _MMSMessageXml>::iterator iterMMSMessageXml;

	CFile cFile;
	CString CSVFileName;
	CString DstFile;

	CSVFileName = dstPath + L"\\MMSMessageXml.csv";	

	if ( !PathFileExists(CSVFileName) )	
	{
		if( cFile.Open( CSVFileName, CFile::modeCreate | CFile::modeWrite ) == FALSE )
			return FALSE;

		USHORT nUniSig = 0xfeff;
		cFile.Write(&nUniSig, 2);

		CString ColHeader = _T("CreateDate\t수발신 상태\tSender\tReciver Number\tMMSMessage\n");
		cFile.Write(ColHeader.GetBuffer(), ColHeader.GetLength()*2);
		cFile.Close();
	}
	CString WriteString;
	for ( iterMMSMessageXml = mMMSMessageXml.begin() ; iterMMSMessageXml != mMMSMessageXml.end(); ++iterMMSMessageXml	)
	{
		//CSV 파일 존재 하면 데이터 쓰기
		if ( cFile.Open( CSVFileName, CFile::modeReadWrite | CFile::modeNoTruncate ) == FALSE )
			return FALSE;

		stMMSMessageXml.folder     = iterMMSMessageXml->second.folder; 
		stMMSMessageXml.sender     = iterMMSMessageXml->second.sender;
		stMMSMessageXml.receivers  = iterMMSMessageXml->second.receivers;

		iterMMSMessageXml->second.receivers.Replace(',', '\n'); // 문자열이 포함하는 쉼표 처리
		stMMSMessageXml.receivers	= iterMMSMessageXml->second.receivers;

		stMMSMessageXml.createDate = iterMMSMessageXml->second.createDate;

		iterMMSMessageXml->second.mMsbody.Replace('\"', '\''); // 문자열이 포함하는 따옴표 처리
		stMMSMessageXml.mMsbody    = iterMMSMessageXml->second.mMsbody;

		//입력할 데이터를 쌍따음표로 묶음
		stMMSMessageXml.folder	   = L"\"" + stMMSMessageXml.folder + L"\"";
		stMMSMessageXml.sender     = L"\"" + stMMSMessageXml.sender + L"\"";
		stMMSMessageXml.receivers  = L"\"" + stMMSMessageXml.receivers + L"\"";
		stMMSMessageXml.createDate = L"\"" + stMMSMessageXml.createDate + L"\"";
		stMMSMessageXml.mMsbody    = L"\"" + stMMSMessageXml.mMsbody + L"\"";

		WriteString = stMMSMessageXml.createDate+ L"\t" + stMMSMessageXml.folder + L"\t" + stMMSMessageXml.sender + L"\t" + stMMSMessageXml.receivers + L"\t" + stMMSMessageXml.mMsbody  + L"\n";

		cFile.SeekToEnd();
		cFile.Write(WriteString.GetBuffer(), WriteString.GetLength()*2);
		WriteString.Empty();
		cFile.Close();
	} 

	return TRUE;
}
コード例 #12
0
bool CFirewallOpener::AddToICFdat(CICSRuleInfo &mapping) {
    CFile fICFdat;
    bool ret = false;
    if(fICFdat.Open(GetICFdatFileName(), CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite|CFile::typeBinary)) {
        fICFdat.SeekToEnd();
        ret = AddToICFdat(fICFdat, mapping);
        fICFdat.Close();
    }
    return ret;
}
コード例 #13
0
ファイル: OBDPNDDlgLog.cpp プロジェクト: Aavesh/obd_pnd
void COBDPNDDlgLog::fSaveLog()
{
	CString strLogFileName;
	CTime time = CTime::GetCurrentTime();

	strLogFileName.Format(_T("%s\\OBD_PND%04d%02d%02d%02d%02d%02d.txt"),
		fCommGetAppPath(),time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond());

	char * bufData = NULL;
	CFile   file;   
	CString strCur;	
	WORD wStrLen = 0;

	if(!file.Open(strLogFileName,CFile::modeReadWrite))   
	{   
		file.Open(strLogFileName,CFile::modeCreate|CFile::modeReadWrite);  		
	}   

	file.SeekToEnd();

	for (int i=0;i<m_vecLogInfo.size();i++)
	{
		strCur = m_vecLogInfo[i].strLogMsg;
		wStrLen = strCur.GetLength()*2+1;
		bufData = new char[wStrLen];
		ZeroMemory(bufData,wStrLen);
		fCommW2C(strCur.GetBuffer(strCur.GetLength()),bufData,wStrLen);
		file.Write(bufData, wStrLen); 
		file.Write("\r\n",2); 					
	}

	//for (int i=0;i<m_listLog.GetCount();i++)
	//{
	//	m_listLog.GetText(i,strCur);
	//	//if (strCur != _T(""))
	//	{
	//		wStrLen = strCur.GetLength()*2+1;
	//		bufData = new char[wStrLen];
	//		ZeroMemory(bufData,wStrLen);
	//		//fW2C(bufData,strCur.GetBuffer(strCur.GetLength()),wStrLen);
	//		fCommW2C(strCur.GetBuffer(strCur.GetLength()),bufData,wStrLen);
	//		file.Write(bufData, wStrLen); 
	//		file.Write("\r\n",2); 		
	//	}		
	//}


	file.Write("\r\n",2); 	
	file.Write("\r\n",2); 

	file.Close(); 

	delete bufData;
	bufData = NULL;
}
コード例 #14
0
ファイル: RegsterDialog.cpp プロジェクト: anzhsoft/Readings
void CRegsterDialog::SaveUserInfo()
{
	UpdateData(TRUE);
	char Userstr[_MAX_PATH] = {0};
	sprintf_s(Userstr,  _MAX_PATH, "%s\\system\\userinfo.bin", CurrentPath);
	CFile cf;
	if(!cf.Open(Userstr, CFile::modeCreate|CFile::modeReadWrite))
		return;
	char username[32] = {0};
	strcpy_s(username, 32, m_username);
	int usernum = cf.GetLength()/sizeof(UserInfo);
	if(usernum != 0){
		UserInfo* Info = (UserInfo*)malloc(usernum*sizeof(UserInfo));
		ZeroMemory(Info, usernum*sizeof(UserInfo));
		cf.Read(Info, usernum*sizeof(UserInfo));
		int hasno = -1;
		for(int i=0; i<usernum; i++){
			UserInfo* tmp = Info+i;
			if(strcmp(tmp->UserName, username) == 0)
				hasno = i;
		}
		if(hasno == -1){
			if(usernum > 9){	//只能存9个
				cf.SeekToBegin();
				cf.Write(Info+1, (usernum-1)*sizeof(UserInfo));
			}
			else
				cf.SeekToEnd();
		}
		else{
			cf.SeekToBegin();
			for(int i=0; i<usernum; i++){
				UserInfo* tmp = Info+i;
				if(i != hasno)
					cf.Write(tmp,sizeof(UserInfo));
			}
			cf.Seek(-(long)sizeof(UserInfo), CFile::end);
		}
		if(Info)
			free(Info);
	}
	UserInfo info = {0};
	strcpy_s(info.UserName, 32, username);
	info.RememberPw = m_remember;
	if(m_remember){
		strcpy_s((char*)info.Pasword, 20, m_password);
		GetDisorString((char*)(info.Pasword), 19);
	}
	srand((unsigned)time(NULL));
	for(int i = 0; i < 4; i++){
		info.Puzzle[i] = rand();
	}
	cf.Write(&info, sizeof(UserInfo));
	cf.Close();
}
コード例 #15
0
ファイル: FileExamDlg.cpp プロジェクト: isongbo/MyCode
/*
*函数介绍:保存修改或添加
*入口参数:(无)
*出口参数:(无)
*返回值:(无)
*/
void CFileExamDlg::OnBnClickedBtnsave() 
{
	CStudentData studentData;
	CFile stuFile;
	
	UpdateData(TRUE);
	switch (m_operID )
	{
	case 0 :  /*添加操作*/
		{
			/*将添加的东西写入文件*/
			ZeroMemory(&studentData,sizeof(studentData));
			wcscpy(studentData.xsbh,m_xsbh);
			wcscpy(studentData.xsxm,m_xsxm);
			wcscpy(studentData.xb,m_xsxb);
			wcscpy(studentData.csrq,m_csrq);
			wcscpy(studentData.bjmc,m_bjmc);
			stuFile.Open(STUDENTFILEPATH,CFile::modeRead | CFile::modeWrite);
			stuFile.SeekToEnd();
			stuFile.Write(&studentData,sizeof(studentData));
			stuFile.Close();
			//更新内存队列
			m_lstStudent.AddTail(studentData);

			SetControlEnable(FALSE);	
			//设置指针移动按钮有效性
			m_iCurPos = m_lstStudent.GetCount()-1;
	        SetNavigatorButton(m_iCurPos);
			break;
		}
	case 1: /*编辑操作*/
		{
			/*将添加的东西写入文件*/
			ZeroMemory(&studentData,sizeof(studentData));
			wcscpy(studentData.xsbh,m_xsbh);
			wcscpy(studentData.xsxm,m_xsxm);
			wcscpy(studentData.xb,m_xsxb);
			wcscpy(studentData.csrq,m_csrq);
			wcscpy(studentData.bjmc,m_bjmc);
			stuFile.Open(STUDENTFILEPATH,CFile::modeRead | CFile::modeWrite);
			stuFile.Seek(sizeof(studentData)*(m_iCurPos) ,CFile::begin);
			stuFile.Write(&studentData,sizeof(studentData));
			stuFile.Close();
			//更新内存队列
			m_lstStudent.SetAt(m_lstStudent.FindIndex(m_iCurPos),studentData);	

		    SetControlEnable(FALSE);	
			//设置指针移动按钮有效性
	        SetNavigatorButton(m_iCurPos);
			break;
		}
	}	
}
コード例 #16
0
BOOL CTextFile::AppendFile( CString& filename, const CString& contents )
/* ============================================================
	Function :		CTextFile::AppendFile
	Description :	Appends contents to filename. Will create 
					the file if it doesn't already exist.
					If filename is empty, the standard file 
					dialog will be displayed, and - if OK is 
					selected - filename will contain the 
					selected filename on return.
					AppendFile will not add eols.
					
	Return :		BOOL					-	TRUE if OK. 
												GetErrorMessage 
												will return errors
	Parameters :	CString& filename		-	file to write to
					const CString& contents	-	contents to write

   ============================================================*/
{

	CFile file;
	CFileException feError;
	BOOL result = TRUE;

	if( filename.IsEmpty() )
		result = GetFilename( TRUE, filename );

	if( result )
	{
		// Write the file
		if( file.Open( filename, CFile::modeWrite | CFile::modeCreate | CFile::modeNoTruncate, &feError ) )
		{

			file.SeekToEnd();
			file.Write( contents, contents.GetLength() );
			file.Close();

		}
		else
		{

			// Set error message
			TCHAR	errBuff[256];
			feError.GetErrorMessage( errBuff, 256 );
			m_error = errBuff;
			result = FALSE;

		}
	}

	return result;

}
コード例 #17
0
void IniNC(int i)
{
	CFile F;
	F.Open(DL_DIR BAC_CFG_LOC_INIVAL, CFile::modeWrite, NULL);
	F.SeekToEnd();

	Ini_Description(i, &F);
//	Ini_Notification_Class(i, &F);


	F.Close();
}
コード例 #18
0
BOOL KiesBNR::CreateWriteSMemoXmlCSVFile(CString dstPath){
	pair<multimap<CString, _SMemoXml>::iterator, multimap<CString, _SMemoXml>::iterator>iter_smemoxml;
	multimap<CString, _SMemoXml>::iterator iterSMemoXml;

	CFile cFile;
	CString CSVFileName;
	CString DstFile;

	CSVFileName = dstPath + L"\\SMemoXml.csv";	

	if ( !PathFileExists(CSVFileName) )	
	{
		if( cFile.Open( CSVFileName, CFile::modeCreate | CFile::modeWrite ) == FALSE )
			return FALSE;

		USHORT nUniSig = 0xfeff;
		cFile.Write(&nUniSig, 2);

		CString ColHeader = _T("MemoNum\tCreateDate\tModifiedDate\tLocation\n");
		cFile.Write(ColHeader.GetBuffer(), ColHeader.GetLength()*2);
		cFile.Close();
	}
	CString WriteString;
	for ( iterSMemoXml = mSMemoXml.begin() ; iterSMemoXml != mSMemoXml.end(); ++iterSMemoXml	)
	{
		//CSV 파일 존재 하면 데이터 쓰기
		if ( cFile.Open( CSVFileName, CFile::modeReadWrite | CFile::modeNoTruncate ) == FALSE )
			return FALSE;

		stSMemoXml.recordID = iterSMemoXml->second.recordID; 
		stSMemoXml.createDate = iterSMemoXml->second.createDate;
		stSMemoXml.modifiedDate = iterSMemoXml->second.modifiedDate;
		stSMemoXml.location_ = iterSMemoXml->second.location_;
		stSMemoXml.locationDecode = iterSMemoXml->second.locationDecode;

		//입력할 데이터를 쌍따음표로 묶음
		stSMemoXml.recordID = L"\"" + stSMemoXml.recordID + L"\"";
		stSMemoXml.createDate = L"\"" + stSMemoXml.createDate + L"\"";
		stSMemoXml.modifiedDate = L"\"" + stSMemoXml.modifiedDate + L"\"";
		stSMemoXml.location_ = L"\"" + stSMemoXml.location_ + L"\"";
		stSMemoXml.locationDecode = L"\"" + stSMemoXml.locationDecode + L"\"";

		WriteString = stSMemoXml.recordID + L"\t" + stSMemoXml.createDate + L"\t" + stSMemoXml.modifiedDate + L"\t" + stSMemoXml.location_ + L"\t" + stSMemoXml.locationDecode + L"\n";

		cFile.SeekToEnd();
		cFile.Write(WriteString.GetBuffer(), WriteString.GetLength()*2);
		WriteString.Empty();
		cFile.Close();
	} 

	return TRUE;
}
コード例 #19
0
ファイル: filecore.cpp プロジェクト: rickerliang/OpenNT
DWORD CFile::GetLength() const
{
	ASSERT_VALID(this);

	DWORD dwLen, dwCur;

	// Seek is a non const operation
	CFile* pFile = (CFile*)this;
	dwCur = pFile->Seek(0L, current);
	dwLen = pFile->SeekToEnd();
	VERIFY(dwCur == (DWORD)pFile->Seek(dwCur, begin));

	return dwLen;
}
コード例 #20
0
ファイル: FileEntry.cpp プロジェクト: vdrive/TrapperKeeper
bool FileEntry::SaveSpecial()
{
	CFile file;
	//Open the maps file and write the file association
	if(file.Open("swarmer_source_maps_special.dat",CFile::modeWrite|CFile::modeCreate|CFile::modeNoTruncate|CFile::typeBinary|CFile::shareDenyWrite)==FALSE)
	{
		return false;
	}

	file.SeekToEnd();
	file.Write(this,sizeof(FileEntry));
	file.Close();
	return true;
}
コード例 #21
0
ファイル: Logger.cpp プロジェクト: wvoice/realtime
void  WriteLog	(CString &pMessage, LPSTR pDebugMode)
{

	   mWriteLog.Lock();
			
	   char pFileName[MAX_PATH]= {0};
	   char path_buffer[_MAX_PATH] = {0};
	   char drive[_MAX_DRIVE]= {0};
       char dir[_MAX_DIR]= {0};
       char fname[_MAX_FNAME]= {0};
       char ext[_MAX_EXT]= {0};
       memset( path_buffer, 0, sizeof( path_buffer ) );
       memset( drive,       0, sizeof( drive ) );
       memset( dir,         0, sizeof( dir ) );
       memset( fname,       0, sizeof( fname ) );
       memset( ext,         0, sizeof( ext ) );

	   GetModuleFileName( 0, path_buffer, 1023 );
      _splitpath ( path_buffer, drive, dir, fname, ext );
	   sprintf(pFileName,"%s%s%s",drive,dir,m_gLogFileName);
	
		CFile f;
		CFileException ex;
		DWORD dwActual = 0;

		if( f.Open( pFileName, CFile::modeRead | CFile::shareDenyWrite, &ex) !=0)
		{
			dwActual = f.SeekToEnd();
			f.Close();
	
			if ( dwActual >=  500000)
		        DeleteFile(pFileName);
		}
	

		FILE *fp = fopen(pFileName, "a");
		if (fp)
		{
			 CString strData;
			 CTime t = CTime::GetCurrentTime();
			 strData.Format("%s,%s,%s,%s\n",strModule, strVersion,t.Format("%c"),pMessage);
			 fputs(strData,fp);
			 fclose(fp);
		}

	mWriteLog.Unlock();
	return;

}
コード例 #22
0
ファイル: mainwnd.cpp プロジェクト: Shadow-Priest/KeyRec
void mainwnd::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: Add your message handler code here and/or call default
	if (buffer_E != 0)
	{
		CTime tm = CTime::GetCurrentTime();
		CString name;
		name.Format(_T("C:\\Users\\usr\\Desktop\\Key_%d_%d.log"), tm.GetMonth(), tm.GetDay());

		CFile file;
		if (!file.Open(name, CFile::modeReadWrite))
		{
			file.Open(name, CFile::modeCreate | CFile::modeReadWrite);
		}
		file.SeekToEnd();
		
		//Encrypt
		UINT64 e = 4787, n = 4922325553; //pub key
		UINT64 buf64[512]; //buf , 8 byte
		int buf64_E = 0;
		for (int i = 0; i < buffer_E; i += 4) // buffer -> buf. In prevent of overflow, we will only fill 4 byte data in a 8 byte varible.
		{
			if (buffer_E - i >= 4)
			{
				memcpy(&buf64[buf64_E], "\0\0\0\0\0\0\0\0", 8);
				memcpy(&buf64[buf64_E], &buffer[i], 4);
				buf64_E++;
			}
			else
			{
				memcpy(&buf64[buf64_E], "\0\0\0\0\0\0\0\0", 8);
				memcpy(&buf64[buf64_E], &buffer[i], buffer_E - i);
				buf64_E++;
			}
		}
		buffer_E = 0;

		for (int i = 0; i < buf64_E; i++)
		{
			buf64[i] = encrypt(buf64[i],e,n);
		}

		file.Write(&buf64, buf64_E * 8);
		file.Close();
		buf64_E = 0;
	}

	CDialogEx::OnTimer(nIDEvent);
}
コード例 #23
0
ファイル: AFCFunction.cpp プロジェクト: liuwanbing/liuwanbing
//异常处理
LONG WINAPI ExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo)
{
	static bool showex=false;
	if(!showex)
		showex=true;
	else
		return EXCEPTION_EXECUTE_HANDLER;
	TCHAR modulename[MAX_PATH],szError[1000],filename[MAX_PATH],*p;
	MEMORY_BASIC_INFORMATION mbinfo;
	VirtualQuery(pExceptionInfo->ExceptionRecord->ExceptionAddress,&mbinfo,sizeof(mbinfo));
	GetModuleFileName((HMODULE)mbinfo.AllocationBase,filename,MAX_PATH);
	p=strrchr(filename,'\\');
	p++;
	lstrcpy(modulename,p);
	try
	{
		SYSTEMTIME st;
		GetLocalTime(&st);
		char FileName[MAX_PATH];
		::CreateDirectory("Error",NULL);
		wsprintf(FileName,"Error\\errorlog-%d-%d.txt",st.wYear,st.wMonth);
		CFile syslog;
		syslog.Open(FileName,CFile::modeNoTruncate| CFile::modeCreate |CFile::modeReadWrite);
		syslog.SeekToEnd();

		char szDate[40];
		wsprintf(szDate,"%d-%d-%d %d:%d:%d\r\n",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
		syslog.Write(szDate,strlen(szDate));
		wsprintf(szError,"异常: 模块:%s, 模块基址:0x%x, 异常代码:0x%x, 指令地址:0x%x",
			modulename,mbinfo.AllocationBase,pExceptionInfo->ExceptionRecord->ExceptionCode,pExceptionInfo->ExceptionRecord->ExceptionAddress);
		syslog.Write(szError,strlen(szError));
		char nextLine[] = "\r\n";
		syslog.Write(nextLine,strlen(nextLine));
		syslog.Close();
	}
	catch(CException *e)
	{TRACE("%s\n",__FUNCTION__);
		e->Delete();
	}
	wsprintf(szError,"本程序遇到错误需要关闭,对此给你带来的不便表示抱歉.\n模块:%s,模块基址:0x%x,异常代码:0x%x,指令地址:0x%x",
		modulename,mbinfo.AllocationBase,pExceptionInfo->ExceptionRecord->ExceptionCode,pExceptionInfo->ExceptionRecord->ExceptionAddress);
	AFCMessageBox(szError,"BZW系统");
	return EXCEPTION_EXECUTE_HANDLER;
}
コード例 #24
0
ファイル: EavooSellStatistic.cpp プロジェクト: FuangCao/cavan
bool CEavooSellStatisticApp::OpenDatabase(CFile &file, const char *pathname, UINT nOpenFlags)
{
	if (pathname == NULL)
	{
		pathname = mDatabasePath;
	}

	if (file.Open(pathname, nOpenFlags, NULL) == false)
	{
		return false;
	}

	if ((nOpenFlags & (CFile::modeWrite | CFile::modeReadWrite)) && (nOpenFlags & CFile::modeNoTruncate))
	{
		file.SeekToEnd();
	}

	return true;
}
コード例 #25
0
ファイル: UtilCore.cpp プロジェクト: densl/test
void UtilCore::setError(char * err)
{
	char msg[4096] = {0};

	SYSTEMTIME mtime;
	GetSystemTime(&mtime);

	sprintf_s(msg, "%04d%02d%02d-%02d.%02d.%02d:  %s\n", mtime.wYear, mtime.wMonth, mtime.wDay, mtime.wHour,mtime.wMinute, mtime.wSecond, err);

	CFile cf;
	BOOL ret = cf.Open(logFile, CFile::modeCreate|CFile::modeWrite|CFile::modeNoTruncate);
	if (ret == FALSE)
		return;

	ULONGLONG fLen = cf.SeekToEnd();

	cf.Write(msg, strlen(msg));
	cf.Close();
}
コード例 #26
0
ファイル: TableFrameSink.cpp プロジェクト: codercold/whgame
//输出信息
void TraceMessage(LPCTSTR pszMessage)
{
	CFile File;
	if ((File.Open(TEXT("TraceData.txt"),CFile::modeWrite)==FALSE)&&
		(File.Open(TEXT("TraceData.txt"),CFile::modeWrite|CFile::modeCreate)==FALSE))
	{
		ASSERT(FALSE);
		return;
	}

	File.SeekToEnd();
	File.Write(pszMessage,lstrlen(pszMessage));
	File.Write(TEXT("\r\n"),lstrlen(TEXT("\r\n")));

	File.Flush();
	File.Close();

	return;
}
コード例 #27
0
void LogFileWrite( LPCSTR logstr )
{
	char ProgPath[256], LogFileName[256];
	memset( ProgPath, 0x00, 256 );
	memset( LogFileName, 0x00, 256 );
	CFile file;
	int loglength;

	GetProgPath(ProgPath);
	loglength = strlen( logstr );

	sprintf( LogFileName, "%s\\Aujard.log", ProgPath);
	
	file.Open( LogFileName, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite );

	file.SeekToEnd();
	file.Write(logstr, loglength);
	file.Close();
}
コード例 #28
0
ファイル: TSocket.cpp プロジェクト: vdrive/TrapperKeeper
void TSocket::LogMessage(char * message)
{

    CFile logfile;
    if (logfile.Open("TSocketLog.txt",CFile::modeCreate|CFile::modeWrite|CFile::modeNoTruncate|CFile::shareDenyNone)== TRUE)
    {
        if(logfile.GetLength()> 100000000)
        {
            logfile.Close();
            remove("TSocketLog.txt");
            logfile.Open("TSocketLog.txt",CFile::modeCreate|CFile::modeWrite|CFile::modeNoTruncate|CFile::shareDenyWrite);
        }
        logfile.SeekToEnd();
        logfile.Write(message, (unsigned int)strlen(message));
        logfile.Write("\r\n",2);
        logfile.Close();
    }

}
コード例 #29
0
ファイル: WorkClass.cpp プロジェクト: zephyrer/mfc-project
/*******************************************************************************
函数名称:				WorkClass::WriteString2File	写字符串内容到文件
================================================================================
参数说明:				const CString strText 文件内容
参数说明:				const CString strSavePath 文件路径
参数说明:				BOOL bUtf_8 是否为UTF-8格式
--------------------------------------------------------------------------------
返回值:					BOOL
--------------------------------------------------------------------------------
文件作者:				King.Sollyu					QQ:191067617
*******************************************************************************/
BOOL WorkClass::WriteString2File( const CString strText,const CString strSavePath,BOOL bUtf_8 )
{
	CFile fileText; CFileException fileException;
	if (fileText.Open(strSavePath,CFile::modeReadWrite|CFile::modeCreate,&fileException) == FALSE)
	{
		ASSERT (FALSE);
		// 打开文件错误,识别什么错误
		switch (fileException.m_cause)
		{
		case CFileException::fileNotFound:	return SetLastError(ERR_FILENOTFOUND),FALSE;break;
		case CFileException::accessDenied:	return SetLastError(ERR_ACCESSDENIED),FALSE;break;
		case CFileException::sharingViolation: return SetLastError(ERR_SHARINGVIOLATION),FALSE;break;
		default:return SetLastError(ERR_UNKNOW),FALSE;break;
		}
	}

	if (bUtf_8 == TRUE)
	{
		unsigned char data[3] = {0xEF, 0xBB, 0xBF};
		fileText.Write(data,3);
		int nSrcLen = (int)wcslen(strText);
		CStringA utf8String(strText);
		int nBufLen = (nSrcLen+1) * 6;
		LPSTR buffer = utf8String.GetBufferSetLength(nBufLen);
		// 将UNICODE 转换成UTF8
		// 需要函数AtlUnicodeToUTF8 头文件: <atlenc.h>
		int nLen = AtlUnicodeToUTF8(strText, nSrcLen, buffer, nBufLen);   
		buffer[nLen] = 0;
		utf8String.ReleaseBuffer();
		//写文件
		fileText.SeekToEnd();
		fileText.Write((LPCSTR)utf8String, nLen);
	}else
	{
		CStringA strANSI(strText);
		fileText.Write((LPCSTR)strANSI,strANSI.GetLength());
	}

	fileText.Close();
	return TRUE;

}
コード例 #30
0
void SoulSeekClientDll::WriteToTextFile(string s)
{
	CFile errorLog;
	CFileException fileException;

	if ( !errorLog.Open( "C:\\SoulSeekLog.txt", CFile::modeCreate |   
			CFile::modeNoTruncate | CFile::modeWrite | CFile::shareDenyWrite, &fileException ) )
	{
		TRACE( "Can't open file %s, error = %u\n",
			"C:\\SoulSeekLog.txt", fileException.m_cause );
	}

	errorLog.SeekToEnd();
	CTime currentTime = CTime::GetCurrentTime();
	char buf[512];
	sprintf(buf,"%s %s",currentTime.Format("%m/%d %H:%M:%S").GetString(),s.c_str());
	errorLog.Write(buf, (UINT)strlen(buf));

	errorLog.Close();
}