Exemplo n.º 1
1
BOOL CPackage::getExecTry( UINT *puTry)
{
	CString csFile;
	CStdioFile myFile;

	try
	{
		// Open package done file
		csFile.Format( _T( "%s\\%s\\%s"), getDownloadFolder(), m_csID, OCS_DOWNLOAD_EXECUTE_TRY);
		if (!myFile.Open( csFile, CFile::modeRead|CFile::typeText|CFile::shareDenyNone))
			return FALSE;
		// Read only first line to get OCS result code
		myFile.ReadString( csFile);
		*puTry = _ttol( csFile);
		myFile.Close();
		return TRUE;
	}
	catch( CException *pEx)
	{
		pEx->Delete();
		myFile.Abort();
		return FALSE;
	}
}
Exemplo n.º 2
0
bool CStringUtils::ReadStringFromTextFile(const CString& path, CString& text)
{
    if (!PathFileExists(path))
        return false;
    try
    {
        CStdioFile file;
        if (!file.Open(path, CFile::modeRead | CFile::shareDenyWrite))
            return false;

        CStringA filecontent;
        UINT filelength = (UINT)file.GetLength();
        int bytesread = (int)file.Read(filecontent.GetBuffer(filelength), filelength);
        filecontent.ReleaseBuffer(bytesread);
        text = CUnicodeUtils::GetUnicode(filecontent);
        file.Close();
    }
    catch (CFileException* pE)
    {
        text.Empty();
        pE->Delete();
    }
    return true;
}
Exemplo n.º 3
0
BOOL CAILog::Open( void )
{
    // open the file of data
    CStdioFile *pFile = new CStdioFile;

    CFileStatus status;
    UINT nAccess = CFile::modeWrite;

    // GetStatus will return TRUE if file exists,
    // or FALSE if it doesn't exist
    if( !CFile::GetStatus( m_sFile, status ) )
        nAccess |= CFile::modeCreate;
    else
        CFile::Remove( m_sFile );
    
    if( !pFile->Open( m_sFile, 
        CFile::modeCreate | CFile::modeWrite | CFile::typeText ) )
    {
        delete pFile;
        return FALSE;
    }
    m_pFile = pFile;
	return TRUE;
}
Exemplo n.º 4
0
BOOL CPackage::setExecTry( UINT uTry)
{
	CStdioFile myFile;
	CString	   csFile;

	csFile.Format( _T( "%s\\%s\\%s"), getDownloadFolder(), m_csID, OCS_DOWNLOAD_EXECUTE_TRY);
	try
	{
		if (!myFile.Open( csFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite))
			return FALSE;
		// First line is result code
		csFile.Format( _T( "%u"), uTry);
		myFile.WriteString( csFile);
		myFile.Close();
	}
	catch( CException *pEx)
	{
		pEx->Delete();
		myFile.Abort();
		DeleteFile( csFile);
		return FALSE;
	}
	return TRUE;
}
BOOL CGridLoad::CheckLoadFileForTStat(GRID_LOAD& glItem)
{
	BOOL bRet = FALSE;
	if(glItem.device > PM_TSTAT5H)  // 不是tstat
	{
		return FALSE;
	}
	CStdioFile file;
	if(file.Open(glItem.hex_file_path,CFile::modeRead | CFile::shareDenyNone))
	{
		CString strRead;
		file.ReadString(	strRead);
		strRead.Trim();
		if(strRead.Find(_T("Tstat")) != -1)
		{
			bRet = TRUE;
		}
	file.Close();
	}
	
	

	return bRet;			
}
//*****************************************************************************	
bool CCeWatchElement::WriteData(CStdioFile& file) const
//*****************************************************************************	
{
	// don't forget to increment the version string if you change anything here
	bool rv = false;
	CString str;

    str = CEWATCH_EXP_NAME + m_Name + CEWATCH_EXP_CRLF;
	file.WriteString(str);

	if (m_Type.GetName().GetLength() > 0)
	{
		str.Format(";%d", (int)m_Type.GetVarKind());
		file.WriteString(m_Type.GetName() + str);
	}
	file.WriteString(CEWATCH_EXP_CRLF);

    str = CEWATCH_EXP_VAL + m_strValue + CEWATCH_EXP_CRLF;
    file.WriteString(str);

	if (m_strFormat.GetLength() > 0)
		file.WriteString(m_strFormat);
	file.WriteString(CEWATCH_EXP_CRLF);

	str.Format("%d", GetHistoryCount());
    str += CEWATCH_EXP_CRLF;
	file.WriteString(str);
	for (int ii = 0; ii < GetHistoryCount(); ii++)
		file.WriteString(GetHistory(ii) + CEWATCH_EXP_CRLF);

	str.Format("%d", GetChildrenCount());
    str += CEWATCH_EXP_CRLF;

	file.WriteString(str);
	rv = true;
	for (ii = 0; ii < GetChildrenCount() && rv; ii++)
		rv &= GetChild(ii)->WriteData(file);

	return rv;;
}
Exemplo n.º 7
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;

}
Exemplo n.º 8
0
/**
* \brief      Write's the signal in the CANoe format and returns false
              if any of the error signal is not stored in the file
* \param[in]  CStdioFile &fileOutput
* \param[out] None
* \return     bool
* \authors    Mahesh.B.S
* \date       15.11.2004
*/
bool CSignal::WriteSignaltofile(CStdioFile &fileOutput)
{
    char acLine[defCON_MAX_LINE_LEN]; // I don't expect one line to be more than this
    bool bResult = true;
    if(m_uiError == SIG_EC_NO_ERR)
    {
        sprintf(acLine," SG_ %s %s:  %u|%u@%c+ (%f,%f) [%lf|%lf] %s %s\n"\
                ,m_sName,m_sMultiplex,m_ucStartBit,m_ucLength,m_ucDataFormat\
                ,m_fScaleFactor,m_fOffset,m_MinValue.dValue\
                ,m_MaxValue.dValue,m_sUnit,m_sNode);
        fileOutput.WriteString(acLine);
    }
    else
        bResult = false;
    return bResult;
}
Exemplo n.º 9
0
BOOL CCapDownload::checkOcsAgentSetupResult()
{
	CString csFile, csCode = ERR_DONE_FAILED, csID;
	CStdioFile myFile;

	csFile.Format(_T("%s\\%s"), getDownloadFolder(), OCS_AGENT_SETUP_DONE);
	if (!fileExists(csFile))
		// No OCS Agent Setup done file
		return TRUE;
	m_pLogger->log(LOG_PRIORITY_DEBUG, _T("DOWNLOAD => Found OCS Inventory Agent Setup result file <%s>"), csFile);
	// Open OCS Agent Setup done file to read exit code and package ID
	try
	{
		if (!myFile.Open(csFile, CFile::modeRead | CFile::typeText | CFile::shareDenyNone))
			return FALSE;
		// First line contains result code and seconf line contains package ID
		myFile.ReadString(csCode);
		myFile.ReadString(csID);
		myFile.Close();
	}
	catch (CException *pEx)
	{
		pEx->Delete();
		myFile.Abort();
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Failed reading OCS Inventory Agent Setup result file <%s>"), csFile);
		return FALSE;
	}
	if (csID.IsEmpty())
	{
		// Upgrading from agent 1.X or previous to 2.0.0.22 ?
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Found result code <%s> for OCS Inventory Agent Setup package but no package ID specified, so remove all packages to avoid running Agent setup in loop !"), csCode);
		COptDownloadPackage::cleanAll();
		return FALSE;
	}
	// All information available => copy result file to Package directory
	csFile.Format(_T("%s\\%s\\%s"), getDownloadFolder(), csID, OCS_DOWNLOAD_DONE);
	if (!CopyFile(myFile.GetFilePath(), csFile, FALSE))
	{
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Failed to copy result code for OCS Inventory Agent Setup package to file <%s>"), csFile);
		return FALSE;
	}
	DeleteFile(myFile.GetFilePath());
	m_pLogger->log(LOG_PRIORITY_NOTICE, _T("DOWNLOAD => Validated result code <%s> for OCS Inventory Agent Setup package <%s>"), csCode, csID);
	return TRUE;
}
Exemplo n.º 10
0
BOOL CRegKey2::ExportKeyToIni(LPCTSTR pszKey, CStdioFile& file) const
{
	ASSERT (pszKey && *pszKey);
	CRegKey2 reg;
	
	if (reg.Open(m_hKey, pszKey, TRUE) == ERROR_SUCCESS)
	{
		BOOL bSectionHasValues = reg.HasValues();
		
		if (bSectionHasValues)
		{
			// write out section heading
			CString sSection;
			sSection.Format(_T("[%s]\n"), pszKey);
			file.WriteString(sSection);

			// write out values
			int nIndex = 0;
			
			while (reg.ExportValueToIni(nIndex, file))
				nIndex++;
		}
		
		// write out subkeys
		CStringArray aSubKeys;
		
		if (reg.GetSubkeyNames(aSubKeys))
		{
			for (int nKey = 0; nKey < aSubKeys.GetSize(); nKey++)
			{
				CString sName = aSubKeys[nKey];
				
				// process subkey
				CString sKeyName;
				sKeyName.Format(_T("%s\\%s"), pszKey, sName);
				
				if (!ExportKeyToIni(sKeyName, file))
					return FALSE;
			}
		}
		
		return TRUE;
	}
	
	// else
	return FALSE;
}
Exemplo n.º 11
0
/**
* \brief      Format_MesgParam_Value
* \param[in]  CStdioFile &fileInput,CList<CParameters,CParameters&>& m_listParam
* \param[out] None
* \return     void
* \authors    Padmaja.A
* \date       16.11.2004
*/
void CParameters::Format_MesgParam_Value(CStdioFile &fileInput,CList<CParameters,CParameters&>& m_listParam)
{
    CParameterValues pVal;
    char acLine[defCON_MAX_LINE_LEN];
    char *pcToken, *pcLine;
    char acTemp[defCON_CHAR_LEN],*pcTemp;
    pcTemp = acTemp;
    //parses the mesg pram other values.
    while(strcmp((fileInput.ReadString(acLine,defCON_MAX_LINE_LEN)),"[END_PARAM_MSG_VAL]\n")!=0)
    {
        char type[defCON_CHAR_LEN];
        pcLine = acLine;
        //get mesg id.
        pcToken=strtok(pcLine,",");
        UINT msgId=unsigned int(atoi(pcToken));
        pcLine=pcLine+strlen(pcToken)+1;
        //get message type and validates teh type.
        pcToken=strtok(pcLine,",");
        strcpy(type,pcToken);
        if(strcmp(type,"X")==0)
            msgId=msgId+2147483648;
        pcLine=pcLine+strlen(pcToken)+1;
        //get other param values.
        pcToken=strtok(pcLine,",");
        pcLine=pcLine+strlen(pcToken)+1;
        pcToken++;
        while(*pcToken && *pcToken!='"')
        {
            *pcTemp++=*pcToken++;
        }
        *pcTemp='\0';
        POSITION posMsg = m_listParam.GetHeadPosition();
        //assigns other values to the matching param defintion.
        while(posMsg != NULL)
        {
            CParameters& rParam = m_listParam.GetNext(posMsg);
            // find matching Parameter from list
            if(strcmp(rParam.m_ParamName,acTemp)==0 )
            {
                pVal.Format_Param_Value(rParam.m_ParamType,pcLine,2,msgId);
                rParam.m_listParamValues[2].AddTail(pVal);
                pcTemp=acTemp;
                break;
            }
        }
    }
}
Exemplo n.º 12
0
/**
 * \brief writes the value descriptors in the given list to the output file
 * \param[in] fileOutput Pointer to the Output file
 * \param[in] m_ucType data type of the value
 * \param[in] m_listSignals List of Value descriptors
 *
 * Writes the value descriptors in the given list to the output file.
 */
void CValueDescriptor::writeValuDescToFile(CStdioFile &fileOutput,char m_ucType,CList<CValueDescriptor,CValueDescriptor&> &m_listValueDescriptor)
{
    char acLine[defVDES_MAX_OUT_STR];
    POSITION posValDesc = m_listValueDescriptor.GetHeadPosition();
    while(posValDesc != NULL)
    {
        CValueDescriptor& rValDesc = m_listValueDescriptor.GetNext(posValDesc);
        switch(m_ucType)
        {
        case CSignal::SIG_TYPE_BOOL:
        case CSignal::SIG_TYPE_UINT:
            sprintf(acLine,"%s \"%s\",%u\n",T_VALUE_DESC,rValDesc.m_acDescriptor,rValDesc.m_value.uiValue);
            break;

        case CSignal::SIG_TYPE_INT:
            sprintf(acLine,"%s \"%s\",%d\n",T_VALUE_DESC,rValDesc.m_acDescriptor,rValDesc.m_value.iValue);
            break;

            // when FLOAT and DOUBLE are supported enable this
            /*
            case CSignal::SIG_TYPE_FLOAT:			
            sprintf(acLine,"%s \"%s\",%f\n",T_VALUE_DESC,rValDesc.m_acDescriptor,rValDesc.m_value.fValue);
            break;

            case CSignal::SIG_TYPE_DOUBLE:
            sprintf(acLine,"%s \"%s\",%f\n",T_VALUE_DESC,rValDesc.m_acDescriptor,rValDesc.m_value.dValue);
            break;
            */

        case CSignal::SIG_TYPE_INT64:
            sprintf(acLine,"%s \"%s\",%I64d\n",T_VALUE_DESC,rValDesc.m_acDescriptor,rValDesc.m_value.i64Value);
            break;

        case CSignal::SIG_TYPE_UINT64:
            sprintf(acLine,"%s \"%s\",%I64u\n",T_VALUE_DESC,rValDesc.m_acDescriptor,rValDesc.m_value.ui64Value);
            break;

        default:
            break;
        }

        fileOutput.WriteString(acLine);	
    }
    return;
}
Exemplo n.º 13
0
BOOL CKrb4RealmHostMaintenance::OnApply()
{
	CStdioFile krbCon;
	if (!krbCon.Open(CKrbProperties::m_krbPath, CFile::modeCreate |
														 CFile::modeNoTruncate |
														 CFile::modeReadWrite))
	{
		LeashErrorBox("OnApply::Can't open Configuration File",
					  CKrbProperties::m_krbPath);
		return TRUE;
	}

	memset(lineBuf, '\0', sizeof(lineBuf));
	if (!krbCon.ReadString(lineBuf, sizeof(lineBuf)))
	{
//-----ADL----///strcpy(lineBuf, CKrb4ConfigOptions::m_newDefaultRealm);
		strcat(lineBuf, "\n");
	}

	krbCon.SetLength(0);
	krbCon.WriteString(lineBuf);
	for (INT maxItems = m_RealmHostList.GetCount(), item = 0; item < maxItems; item++)
	{
		memset(lineBuf, '\0', sizeof(lineBuf));
		if (!m_RealmHostList.GetText(item, lineBuf))
          break;

		krbCon.WriteString(lineBuf);
		krbCon.WriteString("\n");
	}

    if ( m_newDnsKdcLookup )
        krbCon.WriteString(".KERBEROS.OPTION. dns\n");

	krbCon.Close();
	return TRUE;
}
Exemplo n.º 14
0
void DLrtfhtml::openfile(CString filename)
{
	CStdioFile rtf;
	rtf.Open(_T("F:\\\\itbook2.tit"),CStdioFile::modeRead);
	int len=rtf.GetLength();
	rtf.SeekToBegin();
	CStringA content;
	rtf.Read(content.GetBuffer(len),len);
	content.ReleaseBuffer();
	rtf.Close();

	char* str,*strd;
	str=strd=new char[len+1];
	memset(str,'\0',sizeof(str));
	int bg,end;
	bg=end=0;
	char* p;
	while((end=content.Find("\\\'",end))>=0)
	{
		if(end==0 || content.GetAt(end-1)!='\\')
		{//转汉字
			CStringA s;
			if(end!=bg)
			{
				strcpy(str,(LPSTR)(LPCSTR)content.Mid(bg,end-bg));
				str+=(end-bg);
			}
			*str=strtol(content.Mid(end+2,2),&p,16);
			str++;
			bg=end+4;
		}
		else
		{// \\' 去斜杆
			if(end!=bg)
			{
				strcpy(str,(LPSTR)(LPCSTR)content.Mid(bg,end-bg-1)); //   '之前还有两个" \ "
				str+=(end-bg-1);
			}
			strcpy(str,(LPSTR)(LPCSTR)content.Mid(end,2));
			str+=2;
			bg=end+2;
		}
		end++;
	}
	int leng=content.GetLength();
	if((content.GetLength()-bg)>2)//如果再最后两个字符找到\'则会=2  当然根据rtf文档绝对不会这样。
		strcpy(str,(LPSTR)(LPCSTR)content.Mid(bg));
	//}
	int  unicodeLen = ::MultiByteToWideChar( CP_ACP,0,strd,-1,NULL,0);  
	MultiByteToWideChar(CP_ACP,0,strd,-1,(LPWSTR)destcon.GetBuffer(unicodeLen),unicodeLen);
	destcon.ReleaseBuffer();
}
Exemplo n.º 15
0
/**
* \brief      Parses the Node Parameter's Other Values(BA_).
* \param[in]  CStdioFile &fileInput,CList<CParameters,CParameters&>& m_listParam
* \param[out] None
* \return     void
* \authors    Padmaja.A
* \date       16.11.2004
*/
void CParameters::Format_NodeParam_Value(CStdioFile &fileInput,CList<CParameters,CParameters&>& m_listParam)
{
    CParameterValues pVal;
    char acLine[defCON_MAX_LINE_LEN];
    char *pcToken, *pcLine;
    char acTemp[defCON_CHAR_LEN],*pcTemp;
    pcTemp = acTemp;
    //parses the node pram other values.
    while(strcmp((fileInput.ReadString(acLine,defCON_MAX_LINE_LEN)),"[END_PARAM_NODE_VAL]\n")!=0)
    {
        char NodeName[defCON_CHAR_LEN];
        pcLine = acLine;
        //get node name.
        pcToken=strtok(pcLine,",");
        if(strlen(pcToken) > 32)
            Truncate_str("parameter Name",pcToken,false);

        strcpy(NodeName,pcToken);
        pcLine=pcLine+strlen(pcToken)+1;
        //get other values.
        pcToken=strtok(NULL,",");
        pcLine=pcLine+strlen(pcToken)+1;
        pcToken++;
        while(*pcToken && *pcToken!='"')
        {
            *pcTemp++=*pcToken++;
        }
        *pcTemp='\0';
        //assigns other values to the matching param.
        POSITION posMsg = m_listParam.GetHeadPosition();
        while(posMsg != NULL)
        {
            CParameters& rParam = m_listParam.GetNext(posMsg);
            // find matching Parameter from list
            if(strcmp(rParam.m_ParamName,acTemp)==0 )
            {
                pVal.Format_Param_Value(rParam.m_ParamType,pcLine,1,0,NodeName);
                rParam.m_listParamValues[1].AddTail(pVal);
                pcTemp=acTemp;
                break;
            }
        }
    }
}
Exemplo n.º 16
0
// 接口:该接口供ElectricModelingDLGFather对象将其所持有的输入数据写入文件
// 将什么参数写入,以什么样的格式写入,均可再次进行
void ElectricModelingDLGFather::PersistenceParameter(void)
{
	CString str;
	CStdioFile input;
	input.Open("parameter.in",CFile::modeWrite | CFile::modeCreate | CFile::typeText);
	str.Format("%d %d %d                                           !nx ny nz\n",
		m_electricModelingDLGChild1.m_edit_mesh_nx,this->m_electricModelingDLGChild1.m_edit_mesh_ny,this->m_electricModelingDLGChild1.m_edit_mesh_nz);
	input.WriteString(str);
	str.Format("%d %d %d                                           !lx ly lz\n",m_electricModelingDLGChild1.m_edit_size_lx,m_electricModelingDLGChild1.m_edit_size_ly,m_electricModelingDLGChild1.m_edit_size_lz);
	input.WriteString(str);
	str.Format("%d %d                                                    !ns nf\n",0,0);
	input.WriteString(str);
	str.Format("%d                                                            !total # of phases\n",m_electricModelingDLGChild1.m_edit_nums_phases);
	input.WriteString(str);

	input.Close();
}
Exemplo n.º 17
0
BOOL CLang::WriteString()
{
	CString str;
	UINT i;

	if(NULL == m_stringAlloc || NULL == m_offsetAlloc)//
	{
		return FALSE;
	}

	CreateDirectory(theApp.ConvertAbsolutePath(_T("Lang")), NULL);//创建文件夹

	str.Format(_T("Lang\\%s.txt"), m_langName[m_activeLang]);
	if(0xFFFFFFFF != GetFileAttributes(theApp.ConvertAbsolutePath(str)))//属性
	{
		return TRUE;
	}

	//open file
	CStdioFile *pFile;
	pFile = new CStdioFile(theApp.ConvertAbsolutePath(str), 
		CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyNone);
	if(NULL == pFile)
	{
		return FALSE;
	}

	USHORT head = UNICODE_TXT_HEAD;
	pFile->Write(&head, 2);
	
	pFile->WriteString(_T("Lang"));//
	pFile->WriteString(_T("{\r\n"));//

	for(i = 0; i < IDS_MAX; i++)
	{
		str.Format(_T("\"%s\",\r\n"), m_stringAlloc+m_offsetAlloc[i]);//
		pFile->WriteString(str);
	}

	pFile->WriteString(_T("}\r\n"));//

	pFile->Close();
	delete pFile;

	return TRUE;
}
Exemplo n.º 18
0
// 接口:该接口可以将对话框中的参数写入一个文件
void CalculateDlgFather::PersistenceParameter()
{
	CString str;
	CStdioFile input;
	input.Open(".\\spin\\input.dat",CFile::modeWrite | CFile::modeCreate | CFile::typeText);
	str.Format("%0.1f %0.1f %0.1f %0.1f      !dx,dy,dz,dt\n",
		this->m_calculateDlgChild1->m_edit_dx,this->m_calculateDlgChild1->m_edit_dy,this->m_calculateDlgChild1->m_edit_dz,this->m_calculateDlgChild1->m_edit_time_step_size);
	input.WriteString(str);
	str.Format("%d %d %d         !numsteps,stepst1,noise_steps\n",m_calculateDlgChild2->m_edit_total_nums_of_steps,m_calculateDlgChild2->m_edit_time_steps,m_calculateDlgChild2->m_edit_time_steps_with_noise);
	input.WriteString(str);
	str.Format("%0.1f %0.1f           !L1,Mc,kappa,kappa_c\n",m_calculateDlgChild1->m_edit_atmmobility,m_calculateDlgChild1->m_edit_gradcoef);
	input.WriteString(str);
	str.Format("%d                    !iseed\n",m_calculateDlgChild1->m_edit_random_seed);
	input.WriteString(str);
	str.Format("%0.1f                   !noise_level\n",m_calculateDlgChild1->m_edit_noise);
	input.WriteString(str);
	if (!m_calculateDlgChild1->m_radio_new_start)
	{
		str.Format("%d %d                   !initflag,initcount",0,0);
		input.WriteString(str);
	}

	input.Close();
}
Exemplo n.º 19
0
BOOL ScenarioDataMgr::Read(CStdioFile &file)
{
	BOOL bRet = TRUE;
	CString strTemp;
	strTemp.Empty();
	file.ReadString(strTemp);
	m_NumofScenarios.InitRow(strTemp);
	int nNum = ScenarioNum();
	ScenarioInfo *pInfo = NULL;
	for(int i=0;i<nNum;i++)
	{
		pInfo = Creat();
		file.ReadString(strTemp);
		pInfo->Info(strTemp);
	}
	file.ReadString(strTemp);
	m_StartScenario.InitRow(strTemp);
	POSITION pos = m_InfoList.GetHeadPosition();
	while(pos)
	{
		pInfo = m_InfoList.GetNext(pos);
		file.ReadString(strTemp);
		pInfo->OutPut(strTemp);
	}
	ReadInfo(file);
	if ( !isImpFile )
	{
		file.ReadString( strTemp ) ;
		m_OutputScenarioOrder.InitRow( strTemp ) ;
		file.ReadString( strTemp ) ;
		m_OutputScenarioColor.InitRow( strTemp ) ;
		file.ReadString( strTemp ) ;
		m_OutputNameFormat.InitRow( strTemp ) ;
		file.ReadString( strTemp ) ;
		m_OutputDisplayCurrent.InitRow( strTemp ) ;
	}
	return TRUE;
}
Exemplo n.º 20
0
BOOL CRegKey2::ExportValueToIni(DWORD nIndex, CStdioFile& file) const
{
	TCHAR szName[512];
	DWORD nNameLen = sizeof(szName)/sizeof(TCHAR);
	DWORD dwType;
	
	LONG lResult = ::RegEnumValue(m_hKey, nIndex, szName, &nNameLen,
		NULL, &dwType, NULL, NULL);
	
	// we have a valid key name
	if (lResult == ERROR_SUCCESS)
	{
		CString sValueLine;
		
		switch (dwType)
		{
		case REG_DWORD:
			{
				DWORD dwValue;
				Read(szName, dwValue);
				sValueLine.Format(_T("%s = %lu\n"), szName, dwValue);
			}
			break;
			
		case REG_SZ:
			{
				CString sValue;
				Read(szName, sValue);
				sValueLine.Format(_T("%s = \"%s\"\n"), szName, sValue);
			}
		}
		
		if (!sValueLine.IsEmpty())
			file.WriteString(sValueLine);
		
		return TRUE;
	}
	
	return FALSE;
}
Exemplo n.º 21
0
BOOL CExport::CreateExportFile(const char *strFileName, CObArray *pMp3List, BOOL bReinit )
{
	
	CStdioFile file;
	UINT nFlags = CFile::modeCreate | CFile::modeWrite | CFile::typeText;;

	if( !bReinit )
	{
		nFlags |= CFile::modeNoTruncate;
	}

	try
	{
		if( file.Open( strFileName, nFlags ))
		{
			// Ecriture de l'entete
			if( m_strOutputHeader != "" )
			{
				ConvertSpecialChars( m_strOutputHeader );				
				file.WriteString( m_strOutputHeader );
			}
			// Ecriture des enregistrements
			for( int i = 0 ; i < pMp3List->GetSize() ; i++ )
			{
				CAudioFile* pMp3 = (CAudioFile*) pMp3List->GetAt(i);
				CString strOutput = pMp3->FormatExport( m_strOutputRecord );
				ConvertSpecialChars( strOutput );				
				strOutput += "\n";
				file.WriteString( strOutput );
			}
			// Ecriture de la fin de fichier
			if( m_strOutputFooter != "" )
			{
				ConvertSpecialChars( m_strOutputFooter );
				file.WriteString( m_strOutputFooter );
			}
			file.Close();
		}
	}
	catch ( CFileException *e )
	{
		e->Delete();
		TRACE( "Error exporting data !\n");
		return FALSE;
	}
	return TRUE;
}
Exemplo n.º 22
0
BOOL ScenarioDataMgr::Save(CStdioFile &file)
{
	SaveMark(file);
	file.WriteString(m_NumofScenarios.Save());

	ScenarioInfo *pInfo = NULL;
	POSITION pos = m_InfoList.GetHeadPosition();
	while(pos)
	{
		pInfo = m_InfoList.GetNext(pos);
		file.WriteString(pInfo->Info());
	}

	file.WriteString(m_StartScenario.Save());

	pos = m_InfoList.GetHeadPosition();
	while(pos)
	{
		pInfo = m_InfoList.GetNext(pos);
		file.WriteString(pInfo->OutPut());
	}

	pos = m_InfoList.GetHeadPosition();
	while(pos)
	{
		pInfo = m_InfoList.GetNext(pos);
		pInfo->Save(file);
	}

	m_rawDataSet.Save(file);

	if ( !isImpFile )
	{
		file.WriteString( m_OutputScenarioOrder.Save() ) ;
		file.WriteString( m_OutputScenarioColor.Save() ) ;
		file.WriteString( m_OutputNameFormat.Save() ) ;
		file.WriteString( m_OutputDisplayCurrent.Save() ) ;
	}
	
	return TRUE;
}
Exemplo n.º 23
0
bool CUCConf::Write()
{
CUCInfo *ucinfo;
CStdioFile unicasconf;
CString	element;
CFileException	e;
int		count;

	if (m_List.IsEmpty()) return false;

	if (!_access(m_unicasconf_old, 0)) {
		_unlink(m_unicasconf_old);
	}
	unicasconf.Rename(m_unicasconf, m_unicasconf_old);

	if (!unicasconf.Open(m_unicasconf, CFile::modeCreate | CFile::modeWrite, &e)) return false;

	element.Format("%%%% %-23s %s\n", MASTER_SHM_ID, m_master_shm_id);
	element.MakeUpper();
	unicasconf.WriteString(LPCSTR(element));
	element.Format("%%%% %-23s %s\n", ADMIN_LOG_FILE, m_admin_log_file);
	element.MakeUpper();
	unicasconf.WriteString(LPCSTR(element));
	unicasconf.WriteString("\n\n");

	count = (int) m_List.GetCount();
	for (int i = 0; i < count; i++) {
		ucinfo = (CUCInfo *)m_List.GetAt(m_List.FindIndex(i));
		ucinfo->Compose(unicasconf);
		unicasconf.WriteString("\n\n");
	}

	unicasconf.Close();

	return true;
}
Exemplo n.º 24
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.º 25
0
ErrorStatus::FileError AFTFileDriver::Read(CStdioFile &File,PersistentModel& model)
{
	ErrorStatus::FileError errorMark = ErrorStatus::eFileOK;
	CString strData;
	File.ReadString(strData);
	if(CheckMark(strData))
	{
		AFTDriverMgr mgr;
		if(mgr.Read(File))
		{
			errorMark = m_ScenarioMgr.Read(mgr.GetScenarioMgr(),model.GetScenarioPersist());
		}
		else
		{
			
		}
	}
	else
	{
		errorMark = ErrorStatus::eFileTypeError;
	}
	return errorMark;
}
Exemplo n.º 26
0
CString Recognize(CString szUrl)
{
    CString szResult("");
    if (hasInit == FALSE || chkFilePath.IsEmpty())
	{
		CString szFileName;
		DWORD nProcID = ::GetCurrentProcessId();
		GetProcessNameByProcessID(nProcID, szFileName);

		int index = szFileName.ReverseFind('\\');
		chkFilePath = szFileName.Left(index) + "\\chkcode.txt";

		hasInit = TRUE;
	}
	
    CStdioFile file;
    if (szLastUrl != szUrl)
    {
        if (file.Open(chkFilePath, CFile::modeCreate | CFile::modeReadWrite))
        {
            file.WriteString(szUrl);
            szLastUrl = szUrl;
            file.Close();
        }
    }

	CString szLine("");
    if (file.Open(chkFilePath, CFile::modeRead))
    {
        file.ReadString(szLine);
        if (szLine.GetLength() > szUrl.GetLength() + 1)
        {
            szResult = szLine.Mid(szUrl.GetLength() + 1);
        }
        file.Close();
    }
	
	return szResult;
}
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);
}
Exemplo n.º 28
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.º 29
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.º 30
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();
}