Exemplo n.º 1
0
/******************************************************************************
Function Name  :  GenerateReport
Input(s)       :  -
Output         :  HRESULT
Functionality  :  Genrates the report
Member of      :  CResultGenerator
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  07/04/2011
Modifications  :
Code Tag       :  CS042
******************************************************************************/
HRESULT CResultGenerator::GenerateReport(void)
{
    CStdioFile omReportFile;
    if(omReportFile.Open(m_ouHeaderInfo.m_sReportFile.m_omPath, CFile::modeCreate|CFile::modeReadWrite)!=NULL)
    {
        if(m_ouHeaderInfo.m_sReportFile.m_eType == TXT)
        {

            nGenerateTextReport(omReportFile);
        }
        else
        {
            nGenerateHtmlReport(omReportFile);
        }
        omReportFile.Close();
    }

    return S_OK;
}
Exemplo n.º 2
0
BOOL CPackage::unZip()
{
	CZipArchive cZip;
	CString		csFile;

	// If there is no fragement, assume package unzipped
	if (m_uFrags == 0)
		// No fragment
		return TRUE;
	csFile.Format( _T( "%s\\%s\\%s"), getDownloadFolder(), m_csID, OCS_DOWNLOAD_BUILD);
	try
	{
		cZip.Open( csFile);
		for(ZIP_INDEX_TYPE i=0; i<cZip.GetCount();i++)
			cZip.ExtractFile(i, m_csPath);
		cZip.Close();
		// Create package ID file into unzip directory only if not in store action 
		if (m_csAction != OCS_DOWNLOAD_ACTION_STORE)
		{
			CStdioFile cFile;

			csFile.Format( _T( "%s\\%s"), m_csPath, OCS_DOWNLOAD_PACKAGE_ID);
			if (cFile.Open( csFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText))
			{
				cFile.WriteString( m_csID);
				cFile.Close();
			}
		}
	}
	catch (CException *pE)
	{		
		pE->Delete();
		cZip.Close( CZipArchive::afAfterException);
		return FALSE;			
	}
	catch (std::exception *pEx)
	{
		cZip.Close( CZipArchive::afAfterException);
		delete pEx;
		return FALSE;			
	}
	return TRUE;
}
Exemplo n.º 3
0
void CEditorView::OnPopupSave() 
{
	// TODO: Add your command handler code here
	CString FileName;
	CString WindowText;
	CString DataString;
	static char BASED_CODE szFilter[] = "Text Files (*.txt)|*.txt|Data Files (*.dat)|*.dat|All Files (*.*)|*.*||";
	CFileDialog* pSaveFile = new CFileDialog(FALSE,"dat",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,&szFilter[0],NULL);
	if(IDOK==pSaveFile->DoModal())
	{
		FileName = pSaveFile->GetPathName();
		delete pSaveFile;
		CStdioFile* pFile = new CStdioFile(FileName,CFile::modeWrite | CFile::modeCreate);
		GetWindowText(WindowText);
		pFile->WriteString(WindowText);
		pFile->Close();
		delete pFile;
	}	
}
Exemplo n.º 4
0
bool CBiteThroldWnd::LoadResult()
{
	CString path = m_nConfigFile;						//加载文件参数
	if (path.GetLength() <= 0)
		return false;
	CStdioFile file;
	if (!file.Open(path, CFile::modeRead))
		return false;
	Stringoper oper;
	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();

	char szPath[MAX_PATH];
	if (!m_pAlogrithm[0])
	{
		m_pBase = new CCalcuteColor(m_Winlen);				//创建算法模型
		oper.CStringtoChars(m_nConfigFile, szPath);
		if (!m_pBase->LoadModel(szPath))					//加载
		{
			(*m_pOutPut)(L"无法加载阈值模型,无法计算咬牙!");
			delete m_pBase;
			m_pBase = NULL;
		}
		else
		{
			(*m_pOutPut)(L"加载阈值模型完成!");
			m_pAlogrithm[0] = m_pBase;
		}
		m_pAlogrithm[0] = m_pBase;
	}

	return true;
}
Exemplo n.º 5
0
std::vector<CString> CCSSListCtrl::GetCssFromFile(CString modelFileName)
{
	//区域设定
	char* old_locale = _strdup( setlocale(LC_CTYPE,NULL) );
	setlocale( LC_CTYPE, "chs" );//设定

	m_vecCssStyle.clear();

	std::vector<CString> vecCss;
	CStdioFile file;
	if(!file.Open(modelFileName,CFile::modeRead))
		return vecCss;
	CString readLine;
	bool IsStyle=false;
	while(file.ReadString(readLine))
	{
		if(readLine.Find(_T("<style"))!=-1)
			IsStyle=true;
		if(readLine.Find(_T("</style>"))!=-1){
			IsStyle=false;
			break;
		}
		if(IsStyle){
			int pos=readLine.Find(_T("{"));
			int posEnd=readLine.Find(_T("}"));
			CString cssStyle=readLine.Left(posEnd);
			cssStyle=readLine.Right(posEnd-pos);
			m_vecCssStyle.push_back(cssStyle);

			CString css=readLine.Left(pos);
			css.Replace(_T("."),_T(""));
			vecCss.push_back(css);
		}
	}
	file.Close();

	//恢复区域设定
	setlocale( LC_CTYPE, old_locale );
	free( old_locale );//还原区域设定

	return vecCss;
}
void CBatchSNDlg::WriteSerialNumber(unsigned long SN){
    CStdioFile file;
    CString filepath;
    CString SerialDate;
    CTime time = CTime::GetCurrentTime();

    SerialDate.Format(_T("\n%d,%d-%d-%d  %d:%d:%d"),SN,time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond());

    filepath=g_strExePth+_T("Sensor Serial Record.txt");
    if(!file.Open(filepath, CFile::shareDenyNone|CFile::modeReadWrite))
    {
        return ;
    }

    file.SeekToEnd();

    file.WriteString(SerialDate.GetBuffer());
    //  file.Flush();
    file.Close();
}
// 加载权值文件,得到各层训练好的权重值
void CCreateNetwork::LoadWeightFile(vector<double>* vWeightOfLayer, char* path)
{
	CStdioFile sfp;			//权值文件句柄
	CString csWeightValue;  //存储从文件读出的权值字符串
	string strFilePath;     //完整的权值文件路径

	strFilePath=path;
	if(sfp.Open(strFilePath.c_str(),CFile::modeRead)!=0)
	{
		while(sfp.ReadString(csWeightValue))
		{
			vWeightOfLayer->push_back(atof(csWeightValue));
		}
	}
	else
	{
		cout<<"权值文件:"<<path<<"打开失败!"<<endl;
	}
	sfp.Close();
}
bool TitleScrollCore::ReadInTextFile(CString TextFileName)
{
	CStdioFile fileIn;

	if (fileIn.Open(TextFileName, CFile::modeRead | CFile::shareDenyWrite))
	{
	   CString strTemp;

	   while (fileIn.ReadString(strTemp))
		  cFileToBeScrolled.Add(strTemp);

	   fileIn.Close();
	}
	else
	{
	   return 0;
	}

	return 1;
}
Exemplo n.º 9
0
bool CGumpListView::SaveGumpDesc(LPCTSTR szDescFile)
{
	CListCtrl& ctrl = GetListCtrl();

	CStdioFile file;
	if (!file.Open(szDescFile, CFile::modeCreate | CFile::modeWrite)) return false;

	int id = 0;
	LPCTSTR desc;
	for (int i = 0; i < ctrl.GetItemCount(); i++)
	{
		id = ctrl.GetItemData(i);
		desc = GetGumpDesc(id);
		file.WriteString(GfxSprintf("0x%04X=%s\n",id, desc ? desc : ""));
	}

	file.Close();

	return true;
}
Exemplo n.º 10
0
void CCompilerDlg::OnBnClickedRestore()
{	
	CStdioFile myFileBackup;
	CFileException fileException;
	CString DiyText,strLine;
	DiyText=strLine="";
	CEdit* pDiyText; 
	pDiyText = (CEdit*) GetDlgItem(IDC_EDIT1); 
	if (!myFileBackup.Open(_T("backup.txt"), CFile::modeNoTruncate |  CFile::typeText |  CFile::modeReadWrite, &fileException )){
		MessageBox(_T("恢复失败,请重试"),_T("恢复"),MB_OK);
	}
	while( myFileBackup.ReadString( strLine ) ){
		DiyText += strLine+_T("\r\n");
	}
	pDiyText-> SetWindowText(DiyText);
	MessageBox(_T("恢复成功!"),_T("恢复"),MB_OK);
	myFileBackup.Close();
	DiyText.ReleaseBuffer();
	strLine.ReleaseBuffer();
}
Exemplo n.º 11
0
void GWebCache::WriteWebCacheURLsToFile()
{
	UINT i;

	// Open the hosts.dat file for writing...if the open fails, then who cares
	CStdioFile file;
	MakeSureDirectoryPathExists("Host Cache\\");
	if(file.Open("Host Cache\\web_cache_urls.txt",CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyNone)==FALSE)
	{
		return;
	}

	for(i=0;i<v_web_cache_urls.size();i++)
	{
		file.WriteString(v_web_cache_urls[i].c_str());
		file.WriteString("\n");
	}

	file.Close();
}
Exemplo n.º 12
0
bool COperateCsv::Write()
{
	CStdioFile File;
	if (!File.Open(m_strFileName, CFile::modeCreate | CFile::modeReadWrite| CFile::typeText)) 
	{
		return false;
	}
	CString strBuff;
	for (vector<CDataCell>::iterator iter = m_Data.begin();
		iter != m_Data.end();
		++iter)
	{
		CDataCell pCell;
		pCell = *iter;
		strBuff = pCell.SetFullString();
		File.WriteString(strBuff);
	}
	File.Close();
	return true;
}
Exemplo n.º 13
0
// Loads the access token for current windows user from file.
int SCToken::Load(void)
{
	CFileStatus status;
	CString filePath = GetTokenFilePath();
	if(CFile::GetStatus(filePath, status))
	{
		CStdioFile tokenFile;
		try
		{
			tokenFile.Open(filePath, CFile::shareDenyWrite|CFile::modeRead);
			tokenFile.ReadString(m_sToken);
		}
		catch(CFileException*)
		{
			return -1;
		}
		tokenFile.Close();
	}
	return 0;
}
Exemplo n.º 14
0
CString CKDApp::GetUpdateAppOnLineVer(LPCTSTR lpQueryUrl, LPCTSTR lpQueryKeyword,
	const LONGLONG i64QueryOffset, const short unsigned int iQueryVerSize)
{
	CString sRes;

	CInternetSession session(_T("Check Update App Session"));
	CStdioFile *pFile = NULL;
	TRY {
		pFile = session.OpenURL(lpQueryUrl);
	} CATCH_ALL(e) {
	} END_CATCH_ALL
	if (pFile) {
		CString sPageContext;
		CString sBuf;
		char *pBuf = new char[UPDATE_QUERY_SIZE];

		while (pFile->Read(pBuf, UPDATE_QUERY_SIZE)) {
			sBuf = pBuf;
			sPageContext.Append(sBuf);
		}
		int iPos = sPageContext.Find(lpQueryKeyword);
		if (-1 != iPos) {
			LPCTSTR lpPageContext = sPageContext;
			lpPageContext += iPos + i64QueryOffset;

			LPTSTR lpVersion = new TCHAR[iQueryVerSize + 1];
			_tcsncpy(lpVersion, lpPageContext, iQueryVerSize);
			*(lpVersion + iQueryVerSize) = _T('\0');

			sRes = lpVersion;
			delete [] lpVersion;
		}

		delete pBuf;
		pFile->Close();
		delete pFile;
	}

	session.Close();
	return sRes;
}
Exemplo n.º 15
0
//写到文件中
BOOL CSkinIniFile::WriteFile()
{
	CStdioFile	iniFile;
	if (!iniFile.Open(m_strFilePath,CFile::modeCreate|CFile::modeWrite|CFile::typeText))
	{
		m_strError = "Unable to open ini File!";
		return FALSE;
	}

	CString strLine;
	CSkinSection* pSec = NULL;

	try
	{
		POSITION pos = m_listSection.GetHeadPosition();
		while(pos)
		{
			pSec = m_listSection.GetNext(pos);
			strLine = "[" + pSec->m_strSecName + "]";	//写头部
			iniFile.WriteString(strLine);
			iniFile.WriteString("\n");
			
			POSITION posMap = pSec->m_mapKey.GetStartPosition();
			CString strKey,strVal;
			while (posMap)								//区段数据
			{
				pSec->m_mapKey.GetNextAssoc(posMap,strKey,strVal);
				strLine = strKey + "=" + strVal;
				iniFile.WriteString(strLine);
				iniFile.WriteString("\n");
			}
		}
	}
	catch (...)
	{
		m_strError = "Unable to write file!";
	}
	iniFile.Close();

	return TRUE;
}
Exemplo n.º 16
0
bool CLogFile::Close()
{
    try
    {
        // limit log file growth

        size_t maxLines = (DWORD)m_maxlines;
        size_t newLines = m_newLines.size();
        TrimFile (DWORD(max (maxLines, newLines) - newLines));

        // append new info

        CStdioFile file;

        int retrycounter = 10;
        // try to open the file for about two seconds - some other TSVN process might be
        // writing to the file and we just wait a little for this to finish
        while (!file.Open(m_logfile.GetWinPath(), CFile::typeText | CFile::modeReadWrite | CFile::modeCreate | CFile::modeNoTruncate) && retrycounter)
        {
            retrycounter--;
            Sleep(200);
        }
        if (retrycounter == 0)
            return false;

        file.SeekToEnd();
        for (std::deque<CString>::const_iterator it = m_newLines.begin(); it != m_newLines.end(); ++it)
        {
            file.WriteString(*it);
            file.WriteString(L"\n");
        }
        file.Close();
    }
    catch (CFileException* pE)
    {
        CTraceToOutputDebugString::Instance()(__FUNCTION__ ": CFileException saving log file\n");
        pE->Delete();
        return false;
    }
    return true;
}
Exemplo n.º 17
0
//保存信息到指定文件夹
BOOL CStaticAssistant::StoreEncryptInfo(CMapStringToString *m,CString fileName){
	CStdioFile File;
	try{
		CString key=_T(""), value=_T("");
		File.Open("res/temp.znl",CFile::modeWrite| CFile::modeCreate);
		File.SeekToBegin();
		//遍历Cmap获取数据并写入指定的那个文件
		POSITION pos = m->GetStartPosition();
		while(pos)	{ 
			m->GetNextAssoc(pos,key,value);
			File.WriteString(key+"\n");
			File.WriteString(value+"\n");
			//AfxMessageBox(key+"::"+value);			 
		}
	}catch(...){
		File.Close();
		return false;
		AfxMessageBox("保存重要文件失败,请重试!");
	}
	return true;
}
Exemplo n.º 18
0
bool CHexFileList::WriteFile()
{
	CStdioFile ff;                      // Text file we are reading from
	CFileException fe;                  // Stores file exception info
	CString strLine;                    // One line read in from the file

	// Open the file
	if (!ff.Open(filename_, CFile::modeCreate|CFile::modeWrite|CFile::shareExclusive|CFile::typeText, &fe))
		return false;

	ff.WriteString("; version 3\n");
	for (int ii = 0; ii < name_.size(); ++ii)
	{
		CString ss;
		ss.Format("|%ld|", opened_[ii]);
		ff.WriteString(name_[ii] + ss + data_[ii] + '\n');
	}

	ff.Close();
	return true;
}
Exemplo n.º 19
0
void CFileClipboardDlg::OnBnClickedFileClipboardSave()
{
    CString szFilename;
    CStdioFile fOutput;
    int nIndex;
    CString szText;

    if (GetFileClipboardFilename(FALSE, &szFilename) == TRUE)
    {
        if (fOutput.Open(szFilename, CFile::typeText|CFile::modeWrite|CFile::modeCreate) == TRUE)
        {
            for (nIndex = 0; nIndex < m_cFileClipboardList.GetItemCount() - 1; nIndex++)
            {
                szText = m_cFileClipboardList.GetItemText(nIndex, 0);
                fOutput.Write(szText.GetBuffer(), szText.GetLength());
                fOutput.Write("\n", 1);
            }
            fOutput.Close();
        }
    }
}
Exemplo n.º 20
0
CMatLoader::CMatLoader( char *name, char *path)
{
	CStdioFile file;
	char filename[100];
	sprintf(filename, "%s\\%s.bin", path, name);
	
	if (!file.Open(filename,CFile::modeRead | CFile::typeBinary)) 
	{		
		return;
	}


	int dimCount;
	file.Read(&dimCount, sizeof(int));

	dim.resize(dimCount);

	file.Read(&dim.front(), sizeof(int) * dimCount);

	int totalSize = 1;
	//wcout << name.GetString() <<  "  [ ";
	vector <int>::iterator iter;
	for (iter = dim.begin();iter != dim.end();iter++)
	{
		totalSize *= *iter;
		//if (iter != dim.begin())
		//	cout << " x ";
		//cout << *iter;
	}

	//cout << " ]" << endl;

	data = new double[totalSize];
	// file.Read(&data, sizeof(double) * totalSize);
	file.Read(data, sizeof(double) * totalSize);

	double checksum = accumulate(data, data + totalSize , 0.0);

	file.Close();
}
Exemplo n.º 21
0
void CHardLimit::LoadSettings(CPartFile* file)
{
	SettingsList daten;
	CString datafilepath;
	datafilepath.Format(_T("%s\\%s\\%s.ahl"), thePrefs.GetTempDir(),_T("Extra Lists"),file->GetPartMetFileName());

	CString strLine;
	CStdioFile f;
	if (!f.Open(datafilepath, CFile::modeReadWrite | CFile::typeText))
		return;
	while(f.ReadString(strLine))
	{
		if (strLine.GetAt(0) == '#')
			continue;
		int pos = strLine.Find(_T('\0'));
		if (pos == -1)
			continue;
		CString strData = strLine.Left(pos);
		CSettingsData* newdata = new CSettingsData(_tstol(strData));
		daten.AddTail(newdata);
	}
	f.Close();

	if(daten.GetCount() < 1){
		while (!daten.IsEmpty())
			delete daten.RemoveHead();
		return;
	}

	POSITION pos = daten.GetHeadPosition();
	if(!pos)
		return;

	file->SetMaxSourcesPerFile(((CSettingsData*)daten.GetAt(pos))->dwData);
	daten.GetNext(pos);

	while (!daten.IsEmpty())
		delete daten.RemoveHead();

}
Exemplo n.º 22
0
// Resetfunktion, setzt alle Werte wieder auf NULL
void CGenSectorName::ReadSectorNames(void)
{
	m_strNames.RemoveAll();

	// Standardnamen festlegen, alle Namen von Systemen werden aus Datei eingelesen
	CString csInput;						// auf csInput wird die jeweilige Zeile gespeichert
	CString fileName = CIOData::GetInstance()->GetAppPath() + "Data\\Names\\PlanetNames.data";	// Name des zu Öffnenden Files
	CStdioFile file;
	if (file.Open(fileName, CFile::modeRead | CFile::typeText) && m_strNames.IsEmpty())	// Datei wird geöffnet
		while (file.ReadString(csInput))
		{
			m_strNames.Add(csInput);			// Konnte erfolgreich gelesen werden wird die jeweilige
		}
	else
	{
		AfxMessageBox("Fehler! Datei \"PlanetNames.data\" kann nicht geöffnet werden...");
		exit(1);
	}

	// Datei wird geschlossen
	file.Close();
}
Exemplo n.º 23
0
bool CLogFile::Open(const CTGitPath& logfile)
{
	m_lines.clear();
	m_logfile = logfile;
	if (!logfile.Exists())
	{
		CPathUtils::MakeSureDirectoryPathExists(logfile.GetContainingDirectory().GetWinPath());
		return true;
	}

	try
	{
		CString strLine;
		CStdioFile file;
		int retrycounter = 10;
		// try to open the file for about two seconds - some other TSVN process might be
		// writing to the file and we just wait a little for this to finish
		while (!file.Open(logfile.GetWinPath(), CFile::typeText | CFile::modeRead | CFile::shareDenyWrite) && retrycounter)
		{
			retrycounter--;
			Sleep(200);
		}
		if (retrycounter == 0)
			return false;

		while (file.ReadString(strLine))
		{
			m_lines.push_back(strLine);
		}
		file.Close();
	}
	catch (CFileException* pE)
	{
		TRACE("CFileException loading autolist regex file\n");
		pE->Delete();
		return false;
	}
	return true;
}
Exemplo n.º 24
0
void CSetList::OnLbnDblclkSetList()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	CString		selFileName;
	CStdioFile	dataFile;

	if(m_lstSetting.GetCurSel() < 0)
		return;

	m_lstSetting.GetText(m_lstSetting.GetCurSel(), selFileName);
	selFileName = selFileName + _T(".set");

	dataFile.Open(selFileName, CFile::modeRead | CFile::typeText);
	if(dataFile != NULL)
	{
		dataFile.ReadString(m_setDefaultString);		// Default Setting	
		dataFile.ReadString(m_setRingdownString);		// Ringdown Setting
		dataFile.ReadString(m_setLevelString);			// Level Setting
		dataFile.ReadString(m_Standard_Volt);			// 기준 1볼트
		dataFile.ReadString(m_voltTestStartPosition);	// Volt 1 check start position
		dataFile.ReadString(m_voltTestEndPosition);			// Volt 1 check end position
		dataFile.ReadString(m_rtTestLowPosition);
		dataFile.ReadString(m_rtTestLowLimit);
		dataFile.ReadString(m_rtTestHighPosition);
		dataFile.ReadString(m_rtTestHighLimit);
		dataFile.ReadString(m_test1Min);		 
		dataFile.ReadString(m_test1Max);		 
		dataFile.ReadString(m_test2Min);		 
		dataFile.ReadString(m_test2Max);		 
		dataFile.ReadString(m_testDiff);		 
		dataFile.ReadString(m_levelTestRangeMin);
		dataFile.ReadString(m_levelTestRangeMax);
		dataFile.ReadString(m_levelTestLevelMin);
		dataFile.ReadString(m_levelTestLevelMax);
		dataFile.Close();
	}

	OnOK();
}
Exemplo n.º 25
0
void CCompilerDlg::OnBnClickedRestore2()
{
	// TODO: Add your control notification handler code here
	CStdioFile myFile;
	CFileException fileException;
	CString DiyText;
	//获得EDIT  
	CEdit* pDiyText; 
	pDiyText = (CEdit*) GetDlgItem(IDC_EDIT1); 
	pDiyText-> GetWindowText(DiyText);

	
 	if (!myFile.Open(_T("backup.txt"), CFile::modeCreate |  CFile::typeText |  CFile::modeReadWrite, &fileException )){
		MessageBox(_T("备份失败,请重试"),_T("备份"),MB_OK);
	}
	myFile.Seek(0,CFile::end);
	myFile.WriteString(DiyText);
	MessageBox(_T("备份成功!"),_T("备份"),MB_OK);

	myFile.Close();
	DiyText.ReleaseBuffer();
}
Exemplo n.º 26
0
BOOL CPackage::getFragToDownload( CString &csFragID)
{
	CStdioFile myFile;
	CString csTask;

	csFragID.Empty();
	try
	{
		csTask.Format( _T( "%s\\%s\\%s"), getDownloadFolder(), m_csID, OCS_DOWNLOAD_TASK);
		if (!myFile.Open( csTask, CFile::modeRead|CFile::typeText|CFile::shareDenyNone))
			return FALSE;
		myFile.ReadString( csFragID);
		myFile.Close();
	}
	catch( CException *pEx)
	{
		pEx->Delete();
		myFile.Abort();
		return FALSE;
	}
	return TRUE;
}
Exemplo n.º 27
0
static int readFileInfo(CString &strLine)
{
    CStdioFile file;
    TCHAR* pFileName = (TCHAR*)SVN_LOG_FILE;

    if(!file.Open(pFileName,CFile::modeRead | CFile::typeText)) 
    {
       TRACE(_T("Unable to open file\n"));
       return -1;
    }
    
    file.ReadString(strLine);//MS这里得跳一行
    if(!file.ReadString(strLine))
    {
       TRACE(_T("ReadString Error\n"));
       return -2;
    }
    file.Close();

    TRACE(_T("readFileInfo OK\n"));
    return 0;
}
Exemplo n.º 28
0
//////////////////////////////////
// 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;
}
Exemplo n.º 29
0
BOOL CAppOctetStream::AppendPart(LPCTSTR szContent, 
								 LPCTSTR szParameters, 
								 int nEncoding, 
								 BOOL bPath, 
								 CString & sDestination)
{
	CStdioFile fAttachment;

	// This class handles only file attachments, so
	// it ignores the bPath parameter.
	if( szContent == NULL )
		return FALSE;
	if( !fAttachment.Open( szContent, (CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary) ) )
		return FALSE;
	sDestination += build_sub_header( szContent,
								      szParameters,
									  nEncoding,
									  TRUE );
	attach_file( &fAttachment, CMIMEMessage::BASE64, sDestination );
	fAttachment.Close();
	return TRUE;
}
Exemplo n.º 30
0
void CDlgOutPutControl::OnBnSave()
{
	// TODO: 在此添加控件通知处理程序代码
	static TCHAR BASED_CODE szFilter[] = _T("BAT文件(*.bat)|*.bat| 所有文件(*.*)|*.*||");

	CFileDialog dlg( FALSE,_T("bat"),NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter,this);
	if(IDOK == dlg.DoModal())
	{
		CString strFileName = dlg.GetPathName();
		CStdioFile File;
		if( File.Open( strFileName, CFile::modeCreate | CFile::modeWrite ) )
		{
			CString str = _T("AutoPFA Output Preferences\n");
			File.WriteString(str);
			str = _T("[OUTPUT PREFERENCES]\n");
			File.WriteString(str);

			m_PagePipe.Save(File);
			File.Close();
		}
	}
}