当前位置: 首页>>代码示例>>C++>>正文


C++ CFile::Read方法代码示例

本文整理汇总了C++中CFile::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::Read方法的具体用法?C++ CFile::Read怎么用?C++ CFile::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFile的用法示例。


在下文中一共展示了CFile::Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RipChunk

int CCDDARipJob::RipChunk(CFile& reader, CEncoder* encoder, int& percent)
{
  percent = 0;

  uint8_t stream[1024];

  // get data
  int result = reader.Read(stream, 1024);

  // return if rip is done or on some kind of error
  if (!result)
    return 1;

  // encode data
  int encres=encoder->Encode(result, stream);

  // Get progress indication
  percent = static_cast<int>(reader.GetPosition()*100/reader.GetLength());

  if (reader.GetPosition() == reader.GetLength())
    return 2;

  return -(1-encres);
}
开发者ID:Fury04,项目名称:xbmc,代码行数:24,代码来源:CDDARipJob.cpp

示例2: LoadData

void CSystemTimer::LoadData(CFile & file)
{
    uint32_t TimerDetailsSize, Entries;

    file.Read(&TimerDetailsSize, sizeof(TimerDetailsSize));
    file.Read(&Entries, sizeof(Entries));

    if (TimerDetailsSize != sizeof(TIMER_DETAILS))
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
        return;
    }
    if (Entries != sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]))
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
        return;
    }

    file.Read((void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
    file.Read((void *)&m_LastUpdate, sizeof(m_LastUpdate));
    file.Read(&m_NextTimer, sizeof(m_NextTimer));
    file.Read((void *)&m_Current, sizeof(m_Current));
}
开发者ID:Nekokabu,项目名称:project64,代码行数:23,代码来源:SystemTiming.cpp

示例3: OnRsaDecrypt

void CGenRsaKey::OnRsaDecrypt() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	
	if(m_strSrcPath == "" && m_strDestPath == "")
	{
		MessageBox("请选择要的操作文件路径!");
		return;
	}
	
	CKeyOperation obj_Decrypt;
	//读取待加密文件
	CFile fpSrcFile;
	if(fpSrcFile.Open(m_strSrcPath, CFile::modeRead) == 0)
	{
		MessageBox("读取待解密文件失败!");
		return;
	}
	
	int nSrcFileLen = fpSrcFile.GetLength();
	unsigned char *pbSrcData = new unsigned char [nSrcFileLen+1]; //分配待解密文件缓冲区
	memset(pbSrcData, 0x00, nSrcFileLen+1);
	fpSrcFile.Read(pbSrcData, nSrcFileLen);
	fpSrcFile.Close();
	
	int nDestFileLen = 128;
	unsigned char *pbDestData = new unsigned char [nDestFileLen+1]; //分配加密后文件缓冲区
	memset(pbDestData, 0x00, nDestFileLen+1);
	
	int r = obj_Decrypt.CRYPTAPI_RSADecrypt(pbSrcData, nSrcFileLen, pbDestData, nDestFileLen);
	if(r != 0)
	{
		delete [] pbSrcData;
		pbSrcData = NULL;
		delete [] pbDestData;
		pbDestData = NULL;
		MessageBox("非对称解密失败!");
		return;
	}
	
	//保存加密后的数据为文件
	CFile fpDestFile;
	if(fpDestFile.Open(m_strDestPath, CFile::modeCreate | CFile::modeWrite) == 0)
	{
		MessageBox("创建保存文件失败!");
		return;
	}
	fpDestFile.Write(pbDestData, nDestFileLen);
	fpDestFile.Close();
	
	delete [] pbSrcData;
	pbSrcData = NULL;
	delete [] pbDestData;
	pbDestData = NULL;
	
	MessageBox("非对称解密成功!");
	return;
	
	return;
	
}
开发者ID:HouKun1230,项目名称:MFC-DES,代码行数:62,代码来源:GenRsaKey.cpp

示例4: LoadFromFile

BOOL CModbusS::LoadFromFile(CString strFile)
{
	CFile f;
	CString strBuf,str;
	try
	{
		if(!f.Open(strFile,CFile::modeRead))
			return FALSE;
		CHAR buffer[4096];
		DWORD dwRead=0;
		// Read in 4096-byte blocks,
		// remember how many bytes were actually read,
		// and try to write that many out. This loop ends
		// when there are no more bytes to read.
		do
		{
			dwRead = f.Read(buffer, 4096);
			if(dwRead > 0)
			{
				int nLen = strBuf.GetLength();
				strBuf+=buffer;
				strBuf.Truncate(nLen+dwRead);
			}
		}
		while (dwRead > 0);
		f.Close();
		//AfxMessageBox(strBuf);
		strBuf.MakeUpper();
		strBuf.Remove(';');
		int nIndex = 0;
		int nProcIndex = -1;
		do
		{
			nIndex = strBuf.Find("\n");
			str = strBuf.Left(nIndex+1);
			if(str.Find("PORT") != -1)
			{
				str.TrimLeft("PORT");
				str.Trim();str.Trim("=");				
				PORT = atoi(str);
			}
			if(str.Find("BAUDRATE") != -1)
			{
				str.TrimLeft("BAUDRATE");
				str.Trim();str.Trim("=");
				BAUDRATE = atoi(str);
			}
			if(str.Find("STOPBITS") != -1)
			{
				str.TrimLeft("STOPBITS");
				str.Trim();str.Trim("=");
				STOPBITS = atoi(str);
			}
			if(str.Find("PARITY") != -1)
			{
				str.TrimLeft("PARITY");
				str.Trim();str.Trim("=");
				PARITY = atoi(str);
			}
			if(str.Find("BYTETIME") != -1)
			{
				str.TrimLeft("BYTETIME");
				str.Trim();str.Trim("=");
				BYTETIME = atoi(str);
			}
			if(str.Find("WAITRESP") != -1)
			{
				str.TrimLeft("WAITRESP");
				str.Trim();str.Trim("=");
				WAITRESP = atoi(str);
			}
			if(str.Find("ADRESS_KP") != -1)
			{
				str.TrimLeft("ADRESS_KP");
				str.Trim();str.Trim("=");
				ADRESS_KP = atoi(str);
			}
			if(str.Find("NEXTMESSAGE") != -1)
			{
				str.TrimLeft("NEXTMESSAGE");
				str.Trim();str.Trim("=");
				NEXTMESSAGE = atoi(str);
			}
			if(str.Find("NUMBER_OF_PRIBOR") != -1)
			{
				str.TrimLeft("NUMBER_OF_PRIBOR");
				str.Trim();str.Trim("=");
				NUMBER_OF_PRIBOR = atoi(str);
			}
			if(str.Find("NUMBER_NO_ANSWER") != -1)
			{
				str.TrimLeft("NUMBER_NO_ANSWER");
				str.Trim();str.Trim("=");
				NUMBER_NO_ANSWER = atoi(str);
			}
			if(str.Find("AMOUNTBYTE") != -1)
			{
				str.TrimLeft("AMOUNTBYTE");
				str.Trim();str.Trim("=");
				AMOUNTBYTE = atoi(str);
//.........这里部分代码省略.........
开发者ID:toschkin,项目名称:KPL,代码行数:101,代码来源:ModbusS.cpp

示例5: KannadaConcatenate

void CDoc::KannadaConcatenate()
{
	int i,j,temp,Space=0,ind=0;
	BOOL flagpresent,flagnext;
	IIScHeader presenthead,nexthead;
	short int presentsignal[10000],nextsignal[10000],presentpitch[10000],nextpitch[10000];//*EndSignal;
	FILE *presentwave,*nextwave,*target,*missing;
	char present[100],next[100],prescan[100],nextscan[100];
	char Parse[100];
	char c;
	SizeOfSentance = 0;
	int i1=0;
	char p[20] = "parse1.iis";
	do
	{
		c = Path.GetAt(i1);
		if(c == '$')
			break;
		Parse[i1]=c;
		i1++;

	}while(c != '$');
	Parse[i1] = '\0';
	
	strcat(Parse,p);
	
	Parse[strlen(Parse)]= '\0';	
	char Missing[100];
	char M[20] = "missing.txt";
	i1=0;
	do
	{
		c = Path.GetAt(i1);
		if(c == '$')
			break;
		Missing[i1]=c;
		i1++;

	}while(c != '$');
	Missing[i1] = '\0';
	strcat(Missing,M);
	Missing[strlen(Missing)]= '\0';
	char X[100];
	//X=new char [100];
	char x1[20] = "x";
	i1=0;
	do
	{
		c = Path.GetAt(i1);
		if(c == '$')
			break;
		X[i1]=c;
		i1++;

	}while(c != '$');
	X[i1] = '\0';
	strcat(X,x1);
	X[strlen(X)]= '\0';

	CFile file;
	VERIFY(file.Open(Parse,CFile::modeRead));
	//parsed = fopen(Parse,"rt");
	missing = fopen(Missing,"at");
	target = fopen(X,"wb");
	int size=0;
	int duration = 0,Unit=1;
//	int len_present;
//	int pitchmark[300];
	//fscanf(parsed,"%s ",&prescan);
	file.Read(&prescan[0],sizeof(char));
	i=0;
	while(prescan[i] != ' ')
	{
		i++;
		file.Read(&prescan[i],sizeof(char));
	}
	prescan[i] = '\0';

	i1=0;
	do
	{
		c = Path.GetAt(i1);
		if(c == '$')
			break;
		present[i1]=c;
		i1++;

	}while(c != '$');
	present[i1] = '\0';
	strcat(present,prescan);
	int flag_checkdot=0;
	
	
	//TRACE(" \nCunitArray = %d",CUnitArray[ind]);
	while(1)
	{
		//fscanf(parsed,"%s ",&nextscan);
		file.Read(&nextscan[0],sizeof(char));
		i=0;
		while(nextscan[i] != ' ')
//.........这里部分代码省略.........
开发者ID:Mohankumar77,项目名称:text-to-speech,代码行数:101,代码来源:Doc.cpp

示例6: Load

bool CSkeleton::Load(const string& filename)
{
	CFile file;
	if (!file.Open(filename, QIODevice::ReadOnly))
		return false;

	int ver;
	file.Read(ver);
	if (ver < VER_BONE)
	{
		qWarning(("Skeleton version no more supported in '" % filename % "'").toLocal8Bit());
		file.Close();
		return false;
	}

	file.Read(m_ID);
	file.Read(m_boneCount);

	int len;
	Bone* bone;
	m_bones = new Bone[m_boneCount];
	for (int i = 0; i < m_boneCount; i++)
	{
		bone = &m_bones[i];
		file.Read(len);
		file.Read(bone->name, len);
		file.Read(bone->TM);
		file.Read(bone->inverseTM);
		file.Read(bone->localTM);
		file.Read(bone->parentID);
	}

	int temp;
	file.Read(temp);
	m_sendVS = temp != 0;

	file.Read(m_localRH);
	file.Read(m_localShield);
	file.Read(m_localKnuckle);

	if (ver == 5)
	{
		file.Read(m_events, 4);
		file.Read(m_eventParentIDs, 4);
	}
	else if (ver >= 6)
	{
		file.Read(m_events, MAX_MDL_EVENT);
		file.Read(m_eventParentIDs, MAX_MDL_EVENT);
	}

	if (ver == 7)
		file.Read(m_localLH);

	file.Close();
	return true;
}
开发者ID:Aishiro,项目名称:ATools,代码行数:57,代码来源:Motion.cpp

示例7: Run

BOOL CPreviewThread::Run()
{
	ASSERT (m_pPartfile) ;
	CFile destFile;
	CFile srcFile;
	if (!srcFile.Open(m_pPartfile->GetFilePath(), CFile::modeRead | CFile::shareDenyNone))
		return FALSE;
	try{
		uint32 nSize = m_pPartfile->GetFileSize();
		CString strExtension = CString(_tcsrchr(m_pPartfile->GetFileName(), _T('.')));
		CString strPreviewName = m_pPartfile->GetTempPath() + _T("\\") + m_pPartfile->GetFileName().Mid(0, 5) + _T("_preview") + strExtension;
		bool bFullSized = true;
		if (!strExtension.CompareNoCase(_T(".mpg")) || !strExtension.CompareNoCase(_T(".mpeg")))
			bFullSized = false;
		if (!destFile.Open(strPreviewName, CFile::modeWrite | CFile::shareDenyWrite | CFile::modeCreate))
			return FALSE;
		srcFile.SeekToBegin();
		if (bFullSized)
			destFile.SetLength(nSize);
		destFile.SeekToBegin();
		BYTE abyBuffer[4096];
		uint32 nRead;
		while (destFile.GetPosition()+4096 < PARTSIZE*2){
			nRead = srcFile.Read(abyBuffer,4096);
			destFile.Write(abyBuffer,nRead);
		}
		srcFile.Seek(-(PARTSIZE*2),CFile::end);
		uint32 nToGo =PARTSIZE*2;
		if (bFullSized)
			destFile.Seek(-(PARTSIZE*2),CFile::end);
		do{
			nRead = (nToGo - 4096 < 1)? nToGo:4096;
			nToGo -= nRead;
			nRead = srcFile.Read(abyBuffer,4096);
			destFile.Write(abyBuffer,nRead);
		}
		while (nToGo);
		destFile.Close();
		srcFile.Close();
		m_pPartfile->m_bPreviewing = false;

		SHELLEXECUTEINFO SE;
		MEMSET(&SE,0,sizeof(SE));
		SE.fMask = SEE_MASK_NOCLOSEPROCESS ;
		SE.lpVerb = _T("open");
		
		CString path;
		if (!m_player.IsEmpty())
		{
			TCHAR shortPath[512]; //Cax2 short path for vlc
			GetShortPathName(strPreviewName, shortPath, ARRSIZE(shortPath));

			path=thePrefs.GetVideoPlayer();
			int pos = path.ReverseFind(_T('\\'));
			if (pos == -1)
				path.Empty();
			else
				path = path.Left(pos + 1);
			SE.lpFile = m_player.GetBuffer();
			SE.lpParameters=shortPath;
			SE.lpDirectory=path.GetBuffer();
		}
		else
			SE.lpFile = strPreviewName.GetBuffer();
		SE.nShow = SW_SHOW;
		SE.cbSize = sizeof(SE);
		ShellExecuteEx(&SE);
		if (SE.hProcess){
			WaitForSingleObject(SE.hProcess, INFINITE);
			CloseHandle(SE.hProcess);
		}
		CFile::Remove(strPreviewName);
	}	
	catch(CFileException* error){
		m_pPartfile->m_bPreviewing = false;
		error->Delete();
	}
	return TRUE;
}
开发者ID:BackupTheBerlios,项目名称:resurrection,代码行数:79,代码来源:Preview.cpp

示例8: OnOpen

//打开按钮
void CChessManual::OnOpen()
{
	//获取目录
	TCHAR szPath[MAX_PATH]=TEXT("");
	GetCurrentDirectory(sizeof(szPath),szPath);

	//选择文件
	LPCTSTR pszFilter=TEXT("中国象棋棋谱文件 (*.CCM)|*.CCM||");
	CFileDialog DlgOpenManual(TRUE,TEXT("CHM"),NULL,OFN_NOCHANGEDIR|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,pszFilter);
	DlgOpenManual.m_pOFN->lpstrInitialDir=szPath;
	if (DlgOpenManual.DoModal()!=IDOK) return;

	//打开文件
	CFile FileManual;
	if (FileManual.Open(DlgOpenManual.GetPathName(),CFile::modeRead)==FALSE)
	{
		AfxMessageBox(TEXT("无法打开文件,棋谱打开失败!"),MB_ICONSTOP);
		return;
	}

	//判断文件
	DWORD dwFileLength=(DWORD)FileManual.GetLength();
	if (dwFileLength<sizeof(tagChessManualHead))
	{
		AfxMessageBox(TEXT("棋谱文件格式错误,棋谱打开失败!"),MB_ICONSTOP);
		return;
	}

	//文件头
	tagChessManualHead ChessManualHead;
	FileManual.Read(&ChessManualHead,sizeof(ChessManualHead));

	//效验版本
	if (ChessManualHead.wVersion!=VER_MANUAL)
	{
		AfxMessageBox(TEXT("棋谱文件版本错误,棋谱打开失败!"),MB_ICONSTOP);
		return;
	}

	//效验长度
	if ((ChessManualHead.dwManualCount*sizeof(tagChessManual)+sizeof(tagChessManualHead))!=dwFileLength)
	{
		AfxMessageBox(TEXT("棋谱文件长度错误,棋谱打开失败!"),MB_ICONSTOP);
		return;
	}

	//读取棋谱
	tagChessManual * pChessManual=NULL;
	m_ChessManualInfo.SetSize(ChessManualHead.dwManualCount);
	for (DWORD i=0;i<ChessManualHead.dwManualCount;i++)
	{
		pChessManual=&m_ChessManualInfo[i];
		FileManual.Read(pChessManual,sizeof(tagChessManual));
	}

	//关闭文件
	FileManual.Close();

	//设置界面
	m_wChessStep=0;
	m_GameLogic.ResetChessBorad();
	m_ChessBorad.SetChessFrame(255,255,255,255);
	m_ChessBorad.SetChessBorad(m_GameLogic.m_ChessBorad);
	m_ChessBorad.SetChessColor(ChessManualHead.cbChessColor);

	//更新列表
	UpdateManualList();

	//更新控制
	UpdateControl();

	return;
}
开发者ID:Michael-Z,项目名称:qipai-game,代码行数:74,代码来源:ChessManual.cpp

示例9: checkOk

/*
*	check the status of files in filelist.
*	1. files must exist in <path>, which is in filelist and 
*		it's version is higher than current version.
*/
bool CAutoUpdate::checkOk(TCHAR *path)
{
	bool bRet = true;
	CXmlDocumentWrapper xmldoc;
	CXmlNodeWrapper		node;
	CXmlNodeWrapper		nodeT;
	CFile file;
	WCHAR *wbuf=NULL;
	char *mbbuf=NULL;
	CString filelist;
	int i=0;
	viewbar::CMyUtility myut;
	char hashKey[40]={""};
	CString filename,fileurl,fileversion,md5,binpath,filepath;

	// check if file filelist exists in <path>
	filelist += path ;
	filelist += FILELISTNAME ;
	DWORD ret = ::GetFileAttributes(filelist.GetBuffer());
	if( (ret & INVALID_FILE_ATTRIBUTES) ||
		(ret & FILE_ATTRIBUTE_DIRECTORY) )
	{
		bRet = false;
		goto lExit;
	}

	file.Open(filelist.GetBuffer(), CFile::modeRead);
	int fl=file.GetLength();
	mbbuf= new char[fl+1];
	::ZeroMemory(mbbuf, fl+1);
	file.Read(mbbuf, (unsigned int)fl);
	file.Close();

#ifndef _UNICODE 
	xmldoc.LoadXML(mbbuf);
#else
	::ZeroMemory(wbuf, sizeof(WCHAR)*fl+1);
	wbuf = new WCHAR[fl+1];
	MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mbbuf, (int)fl, wbuf, (int)fl);
	xmldoc.LoadXML(wbuf);
#endif
	/*
	*	<vbver>xx.mm.dd.yyyy</vbver>  <-- xx.mm.dd.yyyy -->
	*	<rootpath>http://www.agloco.com/windows/</rootpath>
	*	<filelist>
	*		<file filename="" fileurl="" fileverson="" md5="" ></file>
	*	</fileList>
	*/

	node = xmldoc.AsNode();
	node = node.GetNextSibling();
	node = node.GetNextSibling(); // here, get to <filelist> node

	i=0;
	binpath = myut.GetCurDir();
	for(;node.GetNode(i);i++)
	{
		nodeT = node.GetNode(i);
		filename	= nodeT.GetValue(_T("filename"));		// type.
		fileurl		= nodeT.GetValue(_T("fileurl"));		// destination path.
		fileversion	= nodeT.GetValue(_T("fileversion"));		// version.
		md5			= nodeT.GetValue(_T("md5"));		// url.
		
		// check if file <filepath> exists, and if <its hasdid>==<md5>
		filepath = path + filename;
		memset(hashKey, 0, 40);
		getMD5(filepath, md5);

#ifdef _UNICODE
		// hashKey to unicode.
		WCHAR whashKey[40];
		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, hashKey, 40, whashKey, 40);
		if (_tcscmp(whashKey, md5) !=0 )
		{
			bRet = false;
			break;
		}
#else
		if(strcmp(md5.GetBuffer(), hashKey)!=0)	// current file isn't available.
		{
			bRet = false;
			break;
		}
#endif
	}
lExit:
	delete mbbuf;
	mbbuf=NULL;
	delete wbuf;
	wbuf=NULL;

	return bRet;
}
开发者ID:harrysun2006,项目名称:ag_Client,代码行数:98,代码来源:AutoUpdate.cpp

示例10: LoadBMP

int CRaster::LoadBMP(const char* cfileName)
{
    CFile   file;
    BITMAPFILEHEADER    fileHeader;
    BITMAPINFOHEADER    infoHeader;
    DWORD               width, height;

    LOGPALETTE          *logPal;

    DWORD               Index;
    WORD                bitCount;
    BYTE*               tempImage;

    if(flag) {
        DeleteAllData();
    }/* if */

    if(file.Open(cfileName, CFile::modeRead, NULL) == 0)
        return -1;

    fileName    = cfileName; 

    file.Read(&fileHeader, sizeof(BITMAPFILEHEADER));
    if(fileHeader.bfType != 0x4d42) {
        file.Close();
        return -1;
    } /* if... it's not BMP */

// Load bitmap info
    file.Read(&infoHeader, sizeof(BITMAPINFOHEADER));
    bitCount    = infoHeader.biBitCount;
    if(infoHeader.biCompression != BI_RGB ) {
        file.Close();
        return -2;
    }/* if */
    if( bitCount == 1 ||
        bitCount == 4 ||
        bitCount == 8) { // type of bitmap

        DWORD numColor = infoHeader.biClrUsed;
        if(numColor == 0) {
            numColor = 1<<bitCount;
        }

        imgInfo = (BITMAPINFO*)malloc(  sizeof(BITMAPINFO) 
                                        + sizeof(RGBQUAD) * (1<<bitCount));
        file.Read(imgInfo->bmiColors, sizeof(RGBQUAD) * numColor);

    // Create Palette for 1<<bitCount colors
        pal     = new CPalette();
        logPal  = (LOGPALETTE*)
                    calloc( 1,  sizeof(LOGPALETTE) 
                                    + sizeof(PALETTEENTRY) * (1<<bitCount));

        logPal->palVersion      = 0x300;
        logPal->palNumEntries   = BYTE(1<<bitCount);

        for(Index = 0; Index < numColor; Index++) {

            logPal->palPalEntry[Index].peRed    =
                imgInfo->bmiColors[Index].rgbRed;

            logPal->palPalEntry[Index].peGreen	=
                imgInfo->bmiColors[Index].rgbGreen;

            logPal->palPalEntry[Index].peBlue   =
                imgInfo->bmiColors[Index].rgbBlue;
        }/* for */

        pal->CreatePalette(logPal);
        free(logPal);
    } else if(  bitCount == 24 ) {
        imgInfo = (BITMAPINFO*)malloc(  sizeof(BITMAPINFO) 
                                        + sizeof(RGBQUAD));
    } else {
        file.Close();
        return -2;
    } /* if... not support BMP */

    imgInfo->bmiHeader	= infoHeader;

// Load image data
    width   = imgInfo->bmiHeader.biWidth;
    height  = abs(imgInfo->bmiHeader.biHeight);

    switch(bitCount) {
    case 1:
        shiftPixel  = (width + 7) / 8;
        break;
    case 4:
        shiftPixel  = (width + 1) / 2;
        break;
    case 8:
        shiftPixel  = width;
        break;
    case 24:
        shiftPixel  = width * 3;
        break;
    }/* switch */

//.........这里部分代码省略.........
开发者ID:mikanradojevic,项目名称:sdkpub,代码行数:101,代码来源:Raster.cpp

示例11: openfile

void CRectangle::openfile(CFile &file)
{
	 file.Read(&tprect, sizeof(TP));
	 CLine::openfile(file);
	 name="CRectangle";
}
开发者ID:sergedeh,项目名称:andycad,代码行数:6,代码来源:rectangle.cpp

示例12: LoadFromTuFile

BOOL CModbusM::LoadFromTuFile(CString strFile)
{
	CFile f;
	CString strBuf,str;
	try
	{
		if(!f.Open(strFile,CFile::modeRead))
			return FALSE;
		CHAR buffer[4096];
		DWORD dwRead=0;

		// Read in 4096-byte blocks,
		// remember how many bytes were actually read,
		// and try to write that many out. This loop ends
		// when there are no more bytes to read.
		do
		{
			dwRead = f.Read(buffer, 4096);
			if(dwRead > 0)
			{
				int nLen = strBuf.GetLength();
				strBuf+=buffer;
				strBuf.Truncate(nLen+dwRead);
			}
		}
		while (dwRead > 0);
		f.Close();
		//AfxMessageBox(strBuf);
		strBuf.MakeUpper();
		int nIndex = 0;
		int nProcIndex = -1;
		strBuf.Remove(';');
		int nWaitRespTU = 0;
		do
		{
			nIndex = strBuf.Find("\n");
			str = strBuf.Left(nIndex+1);
			
			if(str.Find("NUMBER_OF_TU") != -1)
			{
				str.TrimLeft("NUMBER_OF_TU");
				str.Trim();str.Trim("=");
				m_TuArray.SetSize(atoi(str));
			}
						
			if(str.Find("MAKE_TU") != -1)
			{
				str.TrimLeft("MAKE_TU");
				str.Trim();str.Trim("=");
				if((atoi(str) > 0)&&(atoi(str) <= m_TuArray.GetSize()))				
					nProcIndex = atoi(str)-1;								
			}			
			if(str.Find("WAIT_RESP_TU") != -1)
			{
				str.TrimLeft("WAIT_RESP_TU");
				str.Trim();str.Trim("=");
				//if((nProcIndex >= 0)&&(nProcIndex < m_TuArray.GetSize()))
					nWaitRespTU = atoi(str);										
			}
			if(str.Find("TU_CLOSER") != -1)
			{
				str.TrimLeft("TU_CLOSER");
				str.Trim();str.Trim("=");
				if((nProcIndex >= 0)&&(nProcIndex < m_TuArray.GetSize()))
					m_TuArray[nProcIndex].TU_CLOSER = atoi(str);										
			}
			if(str.Find("DATATU_OFF") != -1)
			{
				str.TrimLeft("DATATU_OFF");
				str.Trim();str.Trim("=");
				if((nProcIndex >= 0)&&(nProcIndex < m_TuArray.GetSize()))
					m_TuArray[nProcIndex].DATATU_OFF = atoi(str);										
			}
			if(str.Find("DATATU_ON") != -1)
			{
				str.TrimLeft("DATATU_ON");
				str.Trim();str.Trim("=");
				if((nProcIndex >= 0)&&(nProcIndex < m_TuArray.GetSize()))
					m_TuArray[nProcIndex].DATATU_ON = atoi(str);										
			}
			if(str.Find("REGTU_OFF") != -1)
			{
				str.TrimLeft("REGTU_OFF");
				str.Trim();str.Trim("=");
				if((nProcIndex >= 0)&&(nProcIndex < m_TuArray.GetSize()))
					m_TuArray[nProcIndex].REGTU_OFF = atoi(str);										
			}
			if(str.Find("REGTU_ON") != -1)
			{
				str.TrimLeft("REGTU_ON");
				str.Trim();str.Trim("=");
				if((nProcIndex >= 0)&&(nProcIndex < m_TuArray.GetSize()))
					m_TuArray[nProcIndex].REGTU_ON = atoi(str);										
			}
			if(str.Find("FUNCTION") != -1)
			{
				str.TrimLeft("FUNCTION");
				str.Trim();str.Trim("=");
				if((nProcIndex >= 0)&&(nProcIndex < m_TuArray.GetSize()))
					m_TuArray[nProcIndex].FUNCTION = atoi(str);										
//.........这里部分代码省略.........
开发者ID:toschkin,项目名称:KPL,代码行数:101,代码来源:ModbusM.cpp

示例13: LoadFromFile

BOOL CModbusM::LoadFromFile(CString strFile)
{
	CFile f;
	CString strBuf,str;
	try
	{
		if(!f.Open(strFile,CFile::modeRead))
			return FALSE;
		CHAR buffer[4096];
		DWORD dwRead=0;
		// Read in 4096-byte blocks,
		// remember how many bytes were actually read,
		// and try to write that many out. This loop ends
		// when there are no more bytes to read.
		do
		{
			dwRead = f.Read(buffer, 4096);
			if(dwRead > 0)
			{
				int nLen = strBuf.GetLength();
				strBuf+=buffer;
				strBuf.Truncate(nLen+dwRead);
			}
		}
		while (dwRead > 0);
		f.Close();
		//AfxMessageBox(strBuf);
		strBuf.MakeUpper();
		strBuf.Remove(';');
		int nIndex = 0;
		int nProcIndex = -1;
		do
		{
			nIndex = strBuf.Find("\n");
			str = strBuf.Left(nIndex+1);
			if(str.Find("PORT") != -1)
			{
				str.TrimLeft("PORT");
				str.Trim();str.Trim("=");				
				PORT = atoi(str);
			}
			if(str.Find("BAUDRATE") != -1)
			{
				str.TrimLeft("BAUDRATE");
				str.Trim();str.Trim("=");
				BAUDRATE = atoi(str);
			}
			if(str.Find("STOPBITS") != -1)
			{
				str.TrimLeft("STOPBITS");
				str.Trim();str.Trim("=");
				STOPBITS = atoi(str);
			}
			if(str.Find("PARITY") != -1)
			{
				str.TrimLeft("PARITY");
				str.Trim();str.Trim("=");
				PARITY = atoi(str);
			}
			if(str.Find("BYTETIME") != -1)
			{
				str.TrimLeft("BYTETIME");
				str.Trim();str.Trim("=");
				BYTETIME = atoi(str);
			}
			if(str.Find("WAITRESP") != -1)
			{
				str.TrimLeft("WAITRESP");
				str.Trim();str.Trim("=");
				WAITRESP = atoi(str);
			}
			if(str.Find("NEXTMESSAGE") != -1)
			{
				str.TrimLeft("NEXTMESSAGE");
				str.Trim();str.Trim("=");
				NEXTMESSAGE = atoi(str);
			}
			if(str.Find("AMOUNTBYTE") != -1)
			{
				str.TrimLeft("AMOUNTBYTE");
				str.Trim();str.Trim("=");
				AMOUNTBYTE = atoi(str);
			}
			if(str.Find("CONTROLPOTOK") != -1)
			{
				str.TrimLeft("CONTROLPOTOK");
				str.Trim();str.Trim("=");
				CONTROLPOTOK = atoi(str);
			}
			if(str.Find("NUMBER_NO_ANSWER") != -1)
			{
				str.TrimLeft("NUMBER_NO_ANSWER");
				str.Trim();str.Trim("=");
				NUMBER_NO_ANSWER = atoi(str);
			}
			if(str.Find("MODBUS_TYPE") != -1)
			{
				str.TrimLeft("MODBUS_TYPE");
				str.Trim();str.Trim("=");
				MODBUS_TYPE = atoi(str);
//.........这里部分代码省略.........
开发者ID:toschkin,项目名称:KPL,代码行数:101,代码来源:ModbusM.cpp

示例14:

size_t CAPEv2Tag::fread_callback(void *ptr, size_t size, size_t nmemb, void *fp)
{
  CFile *file = (CFile *)fp;
  return file->Read(ptr, size * nmemb) / size;
}
开发者ID:OV3RDOSE,项目名称:xbmc,代码行数:5,代码来源:APEv2Tag.cpp

示例15: Load

bool CEvmFile::Load(const char* sFileName)
{
	CFile oFile;
	if(oFile.Open(sFileName, "r"))
	{
		FocpLog(FOCP_LOG_WARNING, ("Load(%s): open file failure", sFileName));
		return false;
	}

	CEvmFileHead oHead;
	if(sizeof(oHead) != oFile.Read(&oHead, sizeof(oHead)))
	{
		FocpLog(FOCP_LOG_WARNING, ("Load(%s): invalid file", sFileName));
		return false;
	}

	if(!CBinary::MemoryCompare(oHead.magic, "CEXE", 4))
		m_nFileType = EVM_EXE_FILE;
	else if(!CBinary::MemoryCompare(oHead.magic, "CDLL", 4))
		m_nFileType = EVM_DLL_FILE;
	else
	{
		FocpLog(FOCP_LOG_WARNING, ("Load(%s): invalid file", sFileName));
		return false;
	}
	bool bNeedConvert = ((oHead.endian!=0) != IsSmallEndian());
	if(bNeedConvert)
	{
		oHead.version0 = CBinary::U16Code(oHead.version0);
		oHead.version1 = CBinary::U16Code(oHead.version1);
		oHead.version2 = CBinary::U16Code(oHead.version2);
	}
	if(oHead.version0 > EVM_FILE_VERSION_0)
	{
		FocpLog(FOCP_LOG_WARNING, ("Load(%s): version too new", sFileName));
		return false;
	}
	else if(oHead.version0 == EVM_FILE_VERSION_0)
	{
		if(oHead.version1 > EVM_FILE_VERSION_1)
		{
			FocpLog(FOCP_LOG_WARNING, ("Load(%s): version too new", sFileName));
			return false;
		}
		else if(oHead.version1 == EVM_FILE_VERSION_1)
		{
			if(oHead.version2 > EVM_FILE_VERSION_2)
			{
				FocpLog(FOCP_LOG_WARNING, ("Load(%s): version too new", sFileName));
				return false;
			}
		}
	}

	ehc_uint pSection[2], nEntry, nTag = 0;
	bool bReadDone[] = {true,false,false,false,false,false,false,false};

	while(true)
	{
		if(sizeof(pSection) != oFile.Read(pSection, sizeof(pSection)))
		{
			FocpLog(FOCP_LOG_WARNING, ("Load(%s): invalid file", sFileName));
			return false;
		}
		if(bNeedConvert)
		{
			pSection[0] = CBinary::U32Code(pSection[0]);
			pSection[1] = (ehc_int)CBinary::U32Code((ehc_uint)pSection[1]);
		}
		if((pSection[0] >= EVM_INVALID_SECTION) || bReadDone[pSection[0]] || (pSection[0] <= nTag) || (pSection[1] % sizeof(ehc_uint)))
		{
			FocpLog(FOCP_LOG_WARNING, ("Load(%s): invalid file", sFileName));
			return false;
		}
		nTag = pSection[0];
		bReadDone[pSection[0]] = true;
		switch(nTag)
		{
		case EVM_CODESEG_SECTION:
			m_nCodeSize = pSection[1];
			m_pCodeSegment = NULL;
			if(m_nCodeSize)
			{
				m_pCodeSegment = new ehc_char[m_nCodeSize];
				if(m_nCodeSize != oFile.Read(m_pCodeSegment, m_nCodeSize))
				{
					FocpLog(FOCP_LOG_WARNING, ("Load(%s): invalid file", sFileName));
					return false;
				}
			}
			break;
		case EVM_DATASEG_SECTION:
			if(pSection[1] != (ehc_int)sizeof(ehc_uint))
			{
				FocpLog(FOCP_LOG_WARNING, ("Load(%s): invalid file", sFileName));
				return false;
			}
			if(sizeof(ehc_int) != oFile.Read(&m_nDataSize, sizeof(ehc_int)))
			{
				FocpLog(FOCP_LOG_WARNING, ("Load(%s): invalid file", sFileName));
//.........这里部分代码省略.........
开发者ID:nightstyles,项目名称:focp,代码行数:101,代码来源:EvmFile.cpp


注:本文中的CFile::Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。