////////////////////////////////// // addFaceImgArray():添加固定格式训练、测试图片信息(编号、文件名)到txt文件 // // BOOL faceRecognition::addFaceImgArray(char * fileName,char * imgName){ // CStdioFile fwrite; // CString temp=CString(imgName); // temp=temp+"\n"; // try{ // if(fwrite.Open(fileName,CStdioFile::modeReadWrite)==FALSE) // AfxMessageBox("打开文件 "+CString(fileName)+" 失败!!"); // fwrite.SeekToEnd(); // fwrite.WriteString(temp); //自动加上换行符号 // //close() // fwrite.Close(); // }catch(CFileException e) // { // AfxMessageBox("文件写入失败::"+CString(fileName)); // } // return true; // } ////////////////////////////////// // addFaceImgArray():添加固定格式训练、测试图片信息(编号、文件名)到txt文件 // 上面重载函数 BOOL faceRecognition::addFaceImgArray(char *name,bool flag){ CStdioFile fwrite; CString temp=CString(name); temp=temp+"\n";//自动加上换行符号 try{ if(flag==true) {//for train if(fwrite.Open(learnFileListPath,CFile::modeNoTruncate|CStdioFile::modeReadWrite|CStdioFile::modeCreate)==FALSE) AfxMessageBox("打开文件 "+CString(learnFileListPath)+" 失败!!"); }else{ if(fwrite.Open(testFileListPath,CStdioFile::modeReadWrite)==FALSE) AfxMessageBox("打开文件 "+CString(testFileListPath)+" 失败!!"); } fwrite.SeekToEnd(); fwrite.WriteString(temp); //close() fwrite.Close(); }catch(CFileException e) { AfxMessageBox("文件写入失败::"+CString(name)); } return true; }
BOOL CMainFrame::DonwLoadFile(PSTR pURL, LPSTR SaveAsFilePath) { CInternetSession session; CHttpConnection* pServer = NULL; CHttpFile * pHttpFile = NULL; CString strServerName; //去掉http:// CString strObject; INTERNET_PORT nPort; DWORD dwServiceType; DWORD dwHttpRequestFlags = INTERNET_FLAG_NO_AUTO_REDIRECT; //请求标志 const TCHAR szHeaders[]=_T("Accept: text/*\r\nUser-Agent:HttpClient\r\n"); BOOL OK=AfxParseURL( pURL, dwServiceType, strServerName, strObject, nPort ); pServer = session.GetHttpConnection(strServerName, nPort); //获得服务器名 pHttpFile = pServer-> OpenRequest( CHttpConnection::HTTP_VERB_GET, strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags); pHttpFile->AddRequestHeaders(szHeaders); pHttpFile->SendRequest(); //发送请求 CStdioFile f; if( !f.Open( SaveAsFilePath, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary ) ) { return false; } TCHAR szBuf[1024]; int length=0; long a=pHttpFile->GetLength(); while (length=pHttpFile->Read(szBuf, 1023)) f.Write(szBuf,length); f.Close(); pHttpFile ->Close(); pServer ->Close(); if (pHttpFile != NULL) delete pHttpFile; if (pServer != NULL) delete pServer; session.Close(); return true; }
void CConfigFileHandler::SaveFlashSNParam(const CString& strFileName, int &nHWVersion, int & nModelValue) { CStdioFile file; if (file.Open(strFileName, CStdioFile::modeCreate|CStdioFile::modeNoTruncate | CStdioFile::modeReadWrite)) { // CString strTemp; // strTemp.Format(_T("%d"), nHWVersion); // file.WriteString(CString(c_strFlashHWVersion) + strTemp + _T("\n")); // strTemp.Format(_T("%d"), nModelValue); // file.WriteString(CString(c_strFlashSNModel) + strTemp + _T("\n")); // // file.Close(); } }
void CCustomWavFile::OnOK() { m_TextDescriptionEdit.GetWindowText(m_TextDescription); //赋字符值 if (strOpenWavName.IsEmpty() && m_TextDescription =="") { AfxMessageBox("\n 抱歉,情话文件名和文字不能同时为空!\r\n 否则,请按恢复按钮来恢复原始情话. "); return; } bOriginWavPlay=false; //播放定制的情话. if(strWavFile!=""||m_TextDescription!="") { //建一数据文件,保存当前文件名(不含路径),第二次运行程序时自动播放 CStdioFile TxtFile; //创建情话数据文件,保存路径设为主执行程序所在路径 if (!TxtFile.Open(strPath+ "\\lovepet.dat", CFile::modeCreate | CFile::modeWrite | CFile::typeText)) { CString strErrorMessage; strErrorMessage = "创建情话数据文件: "+strPath+"lovepet.dat 失败 !"; AfxMessageBox(strErrorMessage); } else { //写入情话文件名(不含路径,及默认当前路径,好一起发给对方)和文字表达 if(strWavFile!="" && m_TextDescription!="") { TxtFile.WriteString(strWavFile); TxtFile.WriteString ("$$$"); TxtFile.WriteString (m_TextDescription); } else if(m_TextDescription!="") { TxtFile.WriteString ("$$$"); TxtFile.WriteString (m_TextDescription); } else { TxtFile.WriteString(strWavFile); TxtFile.WriteString ("$$$"); } TxtFile.Close(); } } CDialog::OnOK(); }
void CDialogProcess::getJfResultFromFile(int model) { CLineComputeView* pView = (CLineComputeView*)((CMainFrame *)AfxGetMainWnd())->GetActiveView(); CStdioFile file; CString fileName; if(model == 1)//单独绝缘子 { fileName = _T("single_fpj.dat"); } else//耦合模型 { if(0 == pView->m_data->m_windType)//静风 { fileName = _T("jf_couple_fpj.dat"); } } structFpjResult result[10]; CString path = pView->m_data->m_workspace + _T("\\result\\") + fileName; CString line; if(!PathFileExists(path)) { MessageBox(_T("结果文件") + path + _T("不存在!"), MsgCaption); return ; } file.Open(path, CStdioFile::modeRead); int index = 0; while(file.ReadString(line)) { result[index].id = index+1; result[index].lh = abs(_ttof(line.Mid(0, 15).TrimLeft())); result[index].lv = abs(_ttof(line.Mid(15, 15).TrimLeft())); result[index].fpj = abs(_ttof(line.Mid(30, 15).TrimLeft())); index ++; } file.Close(); if(model==1)//单独绝缘子模型 { for(int i=0; i<index; i++) { pView->m_data->m_resultSingleFpj[i] = result[i]; } } else //耦合模型 { for(int i=0; i<index; i++) { pView->m_data->m_resultCoupleFpj[i] = result[i]; } } }
bool CDCGFStringTable::LoadStringTable(CString Filename) { m_Dict.RemoveAll(); CStdioFile f; CString line; if(f.Open(Filename, CFile::modeRead | CFile::typeText)){ while(f.ReadString(line)){ if(line.GetLength() < 1 || line[0]==';') continue; CString Key, String; bool InKey=true; for(int i=0; i<line.GetLength(); i++){ char c = line[i]; if(c=='\t'){ if(InKey){ InKey = false; continue; } else break; } if(c=='\\' && i<line.GetLength()-1){ char c2 = line[i+1]; switch(c2){ case 'n': c = '\n'; i++; break; case 't': c = '\t'; i++; break; case '\\': c = '\\'; i++; break; } } if(InKey) Key+=c; else String+=c; } Key.MakeLower(); if(Key.GetLength() > 0 && Key!="comment" && Key[0]!='$') #if _DEBUG m_Dict[Key] = CString("l:") + String; #else m_Dict[Key] = String; #endif } f.Close(); return true; } else return false; }
void CLogiTextGate::Simulate(CLogiDoc* pDoc) { // Perform Simulation if (m_iStyle == 1) { UINT uTemp = 0; for (int i=0;i<4;i++) { switch ((Node[i])->State) { case HI: uTemp |= 1<<i; break; case UNKNOWN: uTemp = 16; goto NOWAY; } } NOWAY: m_uIndex = uTemp; if (!m_bLoaded) { CStdioFile cf; CString csFullPath; CString csPathName = m_pDocument->GetPathName(); RelativeToFullPath(m_csFileName, csPathName, csFullPath); if (!cf.Open(csFullPath, CFile::modeRead | CFile::shareDenyWrite)) { ::MessageBox(::GetFocus(), csFullPath, L"Could not open File", MB_OK | MB_ICONEXCLAMATION); pDoc->Halt(); // pDoc->m_bKeepGoing = FALSE; return; } for (int i=0;i<16;i++) if (!cf.ReadString(m_pTextArray[i])) break; m_bLoaded = TRUE; m_pTextArray[16] = "Unknown"; cf.Close(); } } }
bool CBiteThroldWnd::SaveResult() { CString path = m_nConfigFile; if (path.GetLength() <= 0) return false; CStdioFile file; if (!file.Open(path, CFile::modeCreate | CFile::modeReadWrite)) return false; Stringoper oper; file.WriteString(L"std="+oper.tocstring(oper.doubletostring(m_BiteThreshold.stdvalue) + '\n')); file.WriteString(L"vol=" + oper.tocstring(oper.doubletostring(m_BiteThreshold.voltvalue) + '\n')); file.Close(); return true; }
void CDlgNote::OnNMClickListTitle(NMHDR *pNMHDR, LRESULT *pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); // TODO: 在此添加控件通知处理程序代码 if(pNMItemActivate->iItem != -1) { m_Edit_strContent=_T(""); CString strFilePath; strFilePath=m_List_ctlTitle.GetItemText(pNMItemActivate->iItem, 1); m_Edit_strTitle=m_List_ctlTitle.GetItemText(pNMItemActivate->iItem, 0); _tsetlocale(LC_ALL, _T("chs")); CStdioFile file; CString strLine=_T(""); CString strText=_T(""); if(file.Open(strFilePath,CFile::modeRead)==TRUE) { while( file.ReadString( strLine )) { strText= strText+strLine+_T("\r\n"); } file.Close(); m_Edit_strContent=strText; } m_Button_ctlSave.EnableButton(TRUE); m_Button_ctlCancel.EnableButton(TRUE); m_Button_ctlSave.Invalidate(TRUE); m_Button_ctlCancel.Invalidate(TRUE); UpdateData(FALSE); } *pResult = 0; }
void CEditListEditor::FillCombo(LPCTSTR strFileName, CComboBox& combo, bool bAllowNull) { CStdioFile nameFile; CString str; if (nameFile.Open(strFileName, CFile::modeRead)) { if (bAllowNull) { combo.AddString(_T("")); } while (nameFile.ReadString(str)) { combo.AddString(str); } nameFile.Close(); } }
void CTests::OnToolsDeleteLogfile() { CStdioFile myFile; CFileException e; CString strFileName = "c:\\temp\\TestOutput.txt"; myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite | CStdioFile::modeNoTruncate, &e ); myFile.Close(); nsCOMPtr<nsILocalFile> theOriginalFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID)); rv = theOriginalFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\TestOutput.txt")); nsCOMPtr<nsIFile> theTestFile = do_QueryInterface(theOriginalFile); rv = theTestFile->Remove(PR_FALSE); }
void CTests::OnToolsViewLogfile() { char theURI[1024]; CStdioFile myFile; CFileException e; CString strFileName = "c:\\temp\\TestOutput.txt"; myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite | CStdioFile::modeNoTruncate, &e ); myFile.Close(); strcpy(theURI, "file://C|/temp/TestOutput.txt"); rv = qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(theURI).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull,nsnull, nsnull); }
void Trace(int n) { if(!((CXFLR5App*)AfxGetApp())->bTrace) return; CStdioFile tf; tf.Open(((CXFLR5App*)AfxGetApp())->TraceFileName, CFile::modeWrite | CFile::typeText); tf.SeekToEnd(); SYSTEMTIME tm; GetLocalTime(&tm); CString str; str.Format("time = %2d:%2d:%2d.%03d nnn=%d \r\n", tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds,n); tf.WriteString(str); tf.Close(); }
//写到指定的行,及替换原来的行 BOOL faceRecognition::addFaceImgArray(char *name,bool flag,int row){ CStdioFile fwrite; CString S1=""; row=row-1; CString temp=CString(name); //temp=temp+"\n";//自动加上换行符号 try{ if(flag==true) {//for train if(fwrite.Open(learnFileListPath,CStdioFile::modeReadWrite|CStdioFile::modeCreate|CStdioFile::modeNoTruncate)==FALSE) AfxMessageBox("打开文件 "+CString(learnFileListPath)+" 失败!!"); }else{ if(fwrite.Open(testFileListPath,CStdioFile::modeReadWrite)==FALSE) AfxMessageBox("打开文件 "+CString(testFileListPath)+" 失败!!"); } fwrite.SeekToBegin(); for(int i=0; i<row; i++){ fwrite.ReadString(S1); } fwrite.ReadString(S1); //指针指向第row+1行开头 ///fwrite.ReadString(S2); fwrite.Seek(-S1.GetLength()-2,CFile::current); //考虑回车换行符//指针指向第row行开头 fwrite.WriteString(temp); // AfxMessageBox(S2); //fwrite.WriteString(temp); // int len=S1.GetLength()-2-temp.GetLength(); // if(len>0) //用指定符号覆盖多余字符 fwrite.SeekToBegin(); fwrite.Close(); }catch(CFileException e) { fwrite.Close(); AfxMessageBox("文件写入失败::"+CString(name)); } return true; }
void GraphView::OnCopyData() { // TODO: Add your command handler code here static TCHAR BASED_CODE szFilter[] = _T("ͼ±íÊý¾Ý(*.txt)|*.txt|All Files (*.*)|*.*||"); CFileDialog dlg(FALSE,_T("txt"),NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter); if(IDOK == dlg.DoModal()) { CStdioFile File; if(File.Open(dlg.GetPathName(),CFile::modeWrite|CFile::modeCreate|CFile::typeText)) { m_UEChart.Save(File); File.Close(); } } }
BOOL DealerHistoryLog::SetDealerLog(CString log) { CStdioFile file; CString strfilename; GetFileName(strfilename); if( !file.Open(strfilename, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite) ) { return FALSE; } file.SeekToEnd(); // file.Write("\r\n",2); file.Write(log, log.GetLength()); file.Close(); return TRUE; }
void CXunJianDlg::OnBnClickedOpenfile() { // TODO: 在此添加控件通知处理程序代码 CStdioFile listfile; if( opened == true || listfile.Open(xj_ipListFileName,CFile::modeRead,0) == false) { //listfile.Close(); m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); CFileDialog FileDlg(true, _T("txt"),NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, "文本文件(*.TXT)|*.TXT|All Files(*.*)|*.*||"); if( FileDlg.DoModal() == IDOK ) { xj_ipListFileName = FileDlg.GetFileName(); listfile.Open(xj_ipListFileName,CFile::modeRead,0); } else return; } xj_ipListFileName = listfile.GetFileName();//FileDlg.GetFileName(); xj_FilePath = listfile.GetFilePath();//FileDlg.GetPathName(); xj_FilePath.Replace(xj_ipListFileName,""); xj_FilePath.Replace("\\","\\\\"); pList= (CListBox *)GetDlgItem(IDC_HOSTLIST); pList->ResetContent(); CString str; while(listfile.ReadString(str)) { if(str.Find("\'") == -1) //空行不加入 ,有 '符号不加入,相当于注释掉此行 { str.Replace(" ",""); //去除所有空格 pList->AddString(str); } } opened = true; listfile.Close(); UpdateData(false); }
void CDiagRunView::write_model_array() { // TODO: Add your command handler code here CStdioFile file; CFileException e; file.Open("model_list.txt",CFile::modeReadWrite|CFile::modeCreate|CFile::shareDenyNone,&e); int count=ModelArray.GetSize(); if (count>0) { for (int i=0; i<count-1; i++) file.WriteString(ModelArray.GetAt(i)+"\n"); file.WriteString(ModelArray.GetAt(count-1)); } file.Close(); }
int CUpdateUtil::CheckFile(CString strPath) { int retval = UPDATE_FILECHECK_RESULT_ERROR; BOOL bFind = CheckFolder(strPath); if(bFind){ CStdioFile stdioOpenFile; if( !stdioOpenFile.Open(strPath, CFile::modeRead | CFile::typeText) ){ if(!stdioOpenFile.Open(strPath, CFile::modeCreate | CFile::typeText)) retval = UPDATE_FILECHECK_RESULT_ERROR; else retval = UPDATE_FILECHECK_RESULT_CREATE; } else{ retval = UPDATE_FILECHECK_RESULT_EXIST; } stdioOpenFile.Close(); } else{ retval = UPDATE_FILECHECK_RESULT_ERROR; } return retval; }
bool CLightWizard::LoadList() { try { //Load LightWiz.ini CString csFile; csFile.Format("%sLightWiz.ini",Main->m_csRootDirectory); CStdioFile pFile; if ( !pFile.Open(csFile, CFile::modeRead | CFile::shareDenyNone) ) { Main->m_log.Add(1,"ERROR: Unable to open file %s", csFile); return false; } BOOL bStatus = TRUE; while ( bStatus ) { CString csLine; bStatus = pFile.ReadString(csLine); if ( !bStatus ) break; csLine = csLine.SpanExcluding("//"); csLine.Trim(); if ( csLine != "" ) { CLightObj * pLight = new (CLightObj); pLight->m_csName = csLine.SpanExcluding(":"); csLine = csLine.Mid(csLine.Find(":") + 1); pLight->m_Light.Add(csLine.SpanExcluding(",")); while (csLine.Find(",") != -1) { csLine = csLine.Mid(csLine.Find(",") + 1); pLight->m_Light.Add(csLine.SpanExcluding(",")); } m_aLights.Add(pLight); } } } catch (CFileException *e) { Main->m_log.Add(1,"ERROR: Caught an exception while reading the file %s. Cause code = %ld", e->m_strFileName, e->m_cause); e->Delete(); } return true; }
BOOL CXsvrApp::InitInstance() { OleInitialize(NULL); AfxEnableControlContainer(); InitializeCriticalSection(& g_cs); CFileFind fFind; CStdioFile file; char buf[MAX_PATH]; GetProgramDirectory(buf); CString fileName; fileName.Format("%s%s", buf, "sys.log"); if (! fFind.FindFile(fileName)) { // AfxMessageBox("File don't existed."); file.Open(fileName, CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone, NULL); } // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CXsvrDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL CLoginDlg::PreTranslateMessage(MSG* pMsg) { // TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다. if(pMsg->message == WM_KEYDOWN) { if(pMsg->wParam == 'A' && GetKeyState(VK_CONTROL) < 0) { CString accountLevel, inputName, inputPwd, inputData; CStdioFile accountFile; unsigned char dataForWrite[1024] = ""; int i = 0, len = 0; if(m_rdUser.GetCheck() == TRUE) accountLevel.Format(_T("%s"), USER_ACCOUNT); else accountLevel.Format(_T("%s"), ADMIN_ACCOUNT); m_edtLoginName.GetWindowText(inputName); m_edtLoginPwd.GetWindowText(inputPwd); if(inputName.IsEmpty() || inputPwd.IsEmpty()) return CDialog::PreTranslateMessage(pMsg); inputData.Format(_T("%s:%s:%s"),inputName, inputPwd, accountLevel); memcpy(dataForWrite, (unsigned char*)(LPCTSTR)inputData, inputData.GetLength()); len = inputData.GetLength(); RTrace(_T("Input Data = %s\n"), inputData); for(i = 0; i < len; i++) { dataForWrite[i] = ~dataForWrite[i]; } dataForWrite[i] = 0x0a; RTrace(_T("Conversioned Data = %s\n"), dataForWrite); accountFile.Open(LOGIN_FILE_NAME, CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate | CFile::typeBinary); accountFile.SeekToEnd(); accountFile.Write(dataForWrite, i + 1); accountFile.Close(); } } return CDialog::PreTranslateMessage(pMsg); }
void CDialingDirDlg::ParseDialingDir() { CStdioFile fDialingDir; HTREEITEM hTreeItem = TVI_ROOT; int nLevel = 0; m_sDialingDir.clear(); m_dialingDirTree.DeleteAllItems(); SetWindowText(m_szDialingDirFilename); if (fDialingDir.Open(m_szDialingDirFilename, CFile::modeRead)) { fDialingDir.ReadString(m_szInput, sizeof(m_szInput)); RecurseDialingDir(&fDialingDir, nLevel, hTreeItem); } SetupIcons(m_dialingDirTree.GetRootItem()); }
void CDXprocessDlg::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 CStdioFile sFile; sFile.Open(mv_filePath,CFile::modeCreate|CFile::modeWrite); int nItemCount=m_dxprocessList.GetItemCount(); CString str; for(int i=0;i<nItemCount;++i) { str=m_dxprocessList.GetItemText(i,0); sFile.WriteString(str); sFile.WriteString(_T("\n")); } sFile.Close(); OnOK(); }
void CMainFrame::OnExitlogin() { // TODO: 在此添加命令处理程序代码 CMenu menu; menu.LoadMenu(IDR_MAINFRAME); AfxGetMainWnd()->SetMenu(&menu); menu.Detach(); CStdioFile File; File.Open(TEXT("current user.txt"),CFile::modeWrite|CFile::modeCreate); char* old_locale=_strdup(setlocale(LC_CTYPE,NULL)); setlocale( LC_CTYPE,"chs"); File.WriteString(TEXT("\n")); setlocale(LC_CTYPE,old_locale); free(old_locale); File.Close(); }
bool Additional_Class::ReadFileL(CString Dir_ConfigFile, vector<CString> &FileData) { CStdioFile FileHandle; bool RunState; RunState = FileHandle.Open(Dir_ConfigFile, CFile::modeRead|CFile::typeText); if (RunState == true) { CString TextContent; while(FileHandle.ReadString(TextContent)) { FileData.push_back(TextContent); } return true; } return false; }
void CCustomWavFile::OnCancel() { CStdioFile TxtFile; //情话数据文件存在,则删除它 if (TxtFile.Open(strPath+"\\lovepet.dat", CFile::modeRead|CFile::typeText)) { TxtFile.Close(); //在恢复原始情话时,删除自定制情话数据文件 TxtFile.Remove(strPath+"\\lovepet.dat"); } CDialog::OnCancel(); }
void DeicepadGroup::RemoveApproachingFlight( AirsideFlightInSim* pFlight ) { #ifdef _DEBUG CStdioFile f; f.Open(_T("C:\\removed_flight.txt"), CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite); f.SeekToEnd(); char cTmp[1024]; pFlight->GetFlightInput()->getAirline(cTmp); pFlight->GetFlightInput()->getDepID(cTmp + strlen(cTmp)); f.WriteString(cTmp); f.WriteString(_T("\n")); #endif AirsideFlightList::iterator ite = std::remove(m_vFlightApproaching.begin(), m_vFlightApproaching.end(), pFlight); ASSERT(ite != m_vFlightApproaching.end() && ite + 1 == m_vFlightApproaching.end()); m_vFlightApproaching.erase(ite, m_vFlightApproaching.end()); }
void ArrayWriterToTmpFile::Writer(ImageArray* img) { CString tmpfilename = GetTempFilePath(L"Image2Code"); CStdioFile tmp; if (tmp.Open(tmpfilename,CFile::modeCreate|CFile::modeWrite|CFile::typeText)) { IWriter(&tmp,img); tmp.Close(); STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); CString command(L"notepad"); command += L" "; command += tmpfilename; BOOL run = CreateProcess( NULL, T2W(command.GetBuffer()), // Command line NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi ); // Pointer to PROCESS_INFORMATION structure if (run) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } else { AfxMessageBox(IDS_IMAGE_NONOTEPAD, MB_OK|MB_ICONSTOP); } } else { AfxMessageBox(IDS_IMAGE_TMPFILEFAIL, MB_OK|MB_ICONSTOP); } }
BOOL CUpdateUtil::MakeClientXMLfile(CItemList *pItemListSoruce, LPCSTR lpszDestFilePath) { if(!pItemListSoruce) return FALSE; CStdioFile writeFile; CString strFilePath = lpszDestFilePath; BOOL bFind = CheckFolder(strFilePath); if(bFind){ if(!writeFile.Open(lpszDestFilePath, (CFile::modeCreate | CFile::modeWrite | CFile::typeText))){ SetLastError(UPDATE_ERROR_CANT_OPEN_XML_FILE); TRACE("UPDATE_ERROR_CANT_OPEN_XML_FILE : %s\n", lpszDestFilePath); return FALSE; } } else{ return FALSE; } UTIL_CANCEL(); CString strWriteLine, strFileName, strVersion, strDownPath, strCheckSum; strWriteLine = "<?xml version=\"1.0\" encoding=\"euc-kr\"?> \n"; strWriteLine += "<update-data> \n\n"; CPtrList* pPLServer = pItemListSoruce->GetPtrList(); POSITION posServer = pPLServer->GetHeadPosition(); while(posServer) { UPDATE_DATA *psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer); strFileName = psiServer->Name; strVersion = psiServer->Version; strDownPath = psiServer->DownPath; strCheckSum = psiServer->CheckSum; strWriteLine += "\t<file name=\"" + strFileName + "\"> \n"; strWriteLine += "\t\t<version>" + strVersion + "</version> \n"; strWriteLine += "\t\t<downpath>" + strDownPath + "</downpath> \n"; strWriteLine += "\t\t<checksum>" + strCheckSum + "</checksum> \n"; strWriteLine += "\t</file> \n\n"; } strWriteLine += "</update-data>"; writeFile.WriteString(strWriteLine); writeFile.Close(); // TRACE("Write Xml File Success \n Contents : \n%s\n", strWriteLine); return TRUE; }