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


C++ CFileStream::Write方法代码示例

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


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

示例1: ExtractThread

int ExtractThread(EXTRACT_THREAD_VIDEO_DATA*	lpETD)
{
	lpETD->dlg->SetDialogState_Muxing();
	lpETD->dlg->ButtonState_START();

	lpETD->dlg->AddProtocolLine("started extracting binary", 4);

	VIDEOSOURCE* v = lpETD->v;
	v->Enable(1);
	CFileStream* f = lpETD->file;
	char cTime[20];
	char* lpBuffer = new char[2<<20];
	int iLastTime = GetTickCount();
	v->ReInit();

	while (!v->IsEndOfStream() && !DoStop()) {
		__int64 iTimecode;
		__int64 iNS = 0;
		DWORD dwSize;
		v->GetFrame(lpBuffer,&dwSize,&iTimecode);
		f->Write(lpBuffer,dwSize);
		if (GetTickCount()-iLastTime>100 || v->IsEndOfStream()) {
			Millisec2Str((iTimecode * v->GetTimecodeScale() + iNS)/ 1000000,cTime);
			
			CUTF8 utf8Time(cTime);
			lpETD->dlg->m_Prg_Frames.SetWindowText(utf8Time.TStr());
			iLastTime+=100;
		}
	}

	lpETD->dlg->SetDialogState_Config();
	lpETD->dlg->ButtonState_STOP();
	delete lpBuffer;
	StopMuxing(false);
	lpETD->file->Close();
	lpETD->dlg->AddProtocol_Separator();
	delete lpETD;

	v->Enable(0);

	return 1;
}
开发者ID:BrunoReX,项目名称:avimuxgui,代码行数:42,代码来源:VideoSourceListBox.cpp

示例2: _ProcessSegment

int CDownload::_ProcessSegment( CRequestPool &request_pool, CSegmentPool &pool, DWORD dwWaitRet, CFileStream &fs, BOOL &gotData )
{
	int ret = 0;
	BOOL bSegmentDone = FALSE;
	int idx = dwWaitRet - 1;
	SegmentPtrs &runnings = pool.GetRunningSegments();
	Segment &s = *runnings[idx];
	CHttpAsyncIn &http = *s.instream;
	EAsyncInState st = http.Process();
	gotData = EAsync_Data==st;
	
	if(EAsync_Finished==st && s.endposition>0 && !s.isDone())
	{
		// 块应该没有下载完成 !		
		MYTRACE(_T("Unfinished Segment(%d) %I64d - %I64d - %I64d\r\n"), s.index, s.startposition, s.currentposition, s.endposition);
		st = EAsync_Failed;
	}

	if( EAsync_Finished==st && s.instream && s.instream->IsLastValidBufferZeroBit() )
	{
		MYTRACE(_T("Finished (BUT LAST BUFFER 1.ZERO) Segment(%d) %I64d - %I64d - %I64d\r\n"), s.index, s.startposition, s.currentposition, s.endposition);
		st = EAsync_Failed;
	}
	
	if(EAsync_Failed==st)
	{
		// NOTE: 需要回滚数据!!! 
		MYTRACE(_T("Queuing Failed Segment(%d) %I64d - %I64d - %I64d\r\n"), s.index, s.startposition, s.currentposition, s.endposition);
		const UrlInfo * urlinfo = s.instream->GetLocationInfo();
		m_locationPool.Put(urlinfo->szUrl, TRUE);
		
		BOOL toRollback = s.instream->IsLastValidBufferZeroBit();

		request_pool.Put( s.instream );
		s.instream = NULL;

		// 回滚 
		if(toRollback)
		{
			_RollbackSegment(s);
		}
		
#if 0 
		if(s.endposition>0)
		{
			int64 iDownloaded = s.currentposition - s.startposition;
			if((s.currentposition-s.startposition) < HTTP_RECEIVE_BUFFER_LENGTH)
			{
				s.currentposition = s.startposition;
			}
			else
			{
				s.currentposition -= HTTP_RECEIVE_BUFFER_LENGTH;
			}
			if((s.currentposition-s.startposition) < MIN_BLOCK)
			{
				s.currentposition = s.startposition;
			}
			
			int64 iDiff = iDownloaded - (s.currentposition - s.startposition);
			m_FileInfo.fileDownloaded -= iDiff; // 回滚下载长度 
			MYTRACE(_T("Rollback Failed Segment(%d) %I64d - %I64d - %I64d  (%d) BYTE\r\n"), s.index, s.startposition, s.currentposition, s.endposition, iDiff);
		}
#endif 

		pool.Put(&s);
		//TODO :notify fail 
		return 1;
	}
	else if(EAsync_Data==st)
	{		
		INTERNET_BUFFERSA *pInetBuff = (INTERNET_BUFFERSA *)http.GetLastBuffer();
		DWORD dwToWrite = pInetBuff->dwBufferLength;
		DWORD dwWrite = 0;
		
		//MYTRACE(_T("%I64d - %I64d - %I64d  %d\r\n"), s.startposition, s.currentposition, s.endposition, dwToWrite);
		if(s.endposition>0)
		{
			ATLASSERT(s.endposition>s.startposition && s.endposition>s.currentposition);
			ATLASSERT(dwToWrite>0 && s.endposition-s.currentposition);
			ATLASSERT(dwToWrite<=(s.endposition-s.currentposition));
			dwToWrite = min(s.endposition-s.currentposition, dwToWrite);
		}
		if (!fs.Write(s.currentposition, pInetBuff->lpvBuffer, dwToWrite, &dwWrite))
		{
			MYTRACE( _T("ProcessState_ReceiveData Write Error: %d/%d\r\n"), dwWrite/dwToWrite );
			m_errCode = DLERR_WRITEFILE;
			return -1;
		}
		else
		{
			s.currentposition += dwToWrite;
			m_FileInfo.fileDownloaded += dwToWrite;
			m_downStat.OnDownData(dwToWrite);
			return 0;
		}
	}
	else if(EAsync_Finished==st)
	{
		ATLASSERT(s.isDone() || s.endposition==-1);
//.........这里部分代码省略.........
开发者ID:6520874,项目名称:pcmanager,代码行数:101,代码来源:Download.cpp


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