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


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

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


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

示例1: Control

void CBlokRtf::Control(CFile &f, int iBlk)
{
	CString m,n,lnS;
	int iR=0,iLn=0;
	int iDel=0;
	int curPos = f.GetPosition();
	m.Format("Тек поз curPos = %i",curPos);
AfxMessageBox(m);

	char* b = new char[iBlk];

	iR = f.Read(b,iBlk);	// Долбанная функция

	curPos = f.GetPosition();
	m.Format("Поз после Read curPos = %i прочитано iR = %i",curPos,iR);
AfxMessageBox(m);
	CString s=_T("");
	for(int i=0;i<iBlk;i++){
		if(_T(' ')==*(b+i) ){
			s+=_T("_");
		}
		else if( _T('\n')==*(b+i)){
			s+=_T("~");
			iDel++;
		}
		else if(_T('\r')==*(b+i)){
			s+=_T("#");
			iDel++;
		}
		else{
			s+=*(b+i);
		}

//		s+=*(b+i);
	}
//	iLn = s.GetLength();
	lnS.Format(" iDel= %i",iDel);
AfxMessageBox(s+'\n'+lnS);
/*	int ln;
	ln=s.GetLength();
	n.Format("Длина строки s = %i k = %i",ln);
AfxMessageBox(s+'\n'+n);
*/
	curPos-=(iBlk+iDel);
//	curPos-=iBlk;

	m.Format("Поз для возврата curPos = %i",curPos);
AfxMessageBox(m);

	f.Seek(curPos,CFile::begin);

	curPos = f.GetPosition();
	m.Format("Тек поз после Seek назад на исх curPos = %i",curPos);
AfxMessageBox(m);
	delete [] b;

}
开发者ID:03bekjob,项目名称:Strg,代码行数:57,代码来源:BlokRtf.cpp

示例2: OnButtonHistCompact

void CHistoryDlg::OnButtonHistCompact() 
{
	// Compact History File
	CWaitCursor wc;

	CFile theHistoryFile;
	CFileException cfe;

	if(theHistoryFile.Open("HISTORY.DAT", CFile::modeReadWrite, &cfe) == FALSE)
	{
		TRACE("CHistoryDlg::BuildHistoryFileStats() - File Not Opened\n");
		return;
	}

	CTaskObject oneTask;

	DWORD dwReadPos = 0;
	DWORD dwWritePos = 0;

	while(oneTask.ReadFromFile(theHistoryFile) == TRUE)
	{
		if(oneTask.m_bHistoryDeleted == TRUE)
			continue;

		dwReadPos = theHistoryFile.GetPosition();

		theHistoryFile.Seek(dwWritePos, CFile::begin);

		oneTask.WriteToFile(theHistoryFile, FALSE);

		dwWritePos = theHistoryFile.GetPosition();

		theHistoryFile.Seek(dwReadPos, CFile::begin);
	}

	theHistoryFile.SetLength(dwWritePos);

	theHistoryFile.Close();

	CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_LIST_HISTORY);

	pListCtrl->DeleteAllItems();

	BuildHistoryFileStats(pListCtrl);

	UpdateButtons();

}
开发者ID:annatar,项目名称:YencPowerPost,代码行数:48,代码来源:HistoryDlg.cpp

示例3:

bool    External::Write_Chunks_Header(   CFile&  file,    short  chunkCode,   unsigned char version,   long&  retSizeFilePos,   CString&  retErrorMesg  )
{


	retErrorMesg.Empty();
	retSizeFilePos =  -1;


	long   sizeBytesAfterChkHdr =  0;    //  will write in later



	CString   retTagString;


	if(    ! Get_Chunks_TagString(   chunkCode,    retTagString,   retErrorMesg  )     )
		return  false;




	file.Write(   retTagString.GetBuffer( 8 ),    8   );

	file.Write(   &version,    1  );     //	unsigned char   version =   10;    ....   1.0



	retSizeFilePos  =      file.GetPosition();     //  return filePos 'just before' we write the 4 bytes for chunk's size

	file.Write(   &sizeBytesAfterChkHdr,    4  );


	return  true;
}
开发者ID:CreativeDetectors,项目名称:PitchScope_Player,代码行数:34,代码来源:External.cpp

示例4: return

long CAPEv2Tag::ftell_callback(void *fp)
{
  CFile *file = (CFile *)fp;
  int64_t pos = file->GetPosition();
  if(pos > LONG_MAX)
    return -1;
  else
    return (long)pos;
}
开发者ID:OV3RDOSE,项目名称:xbmc,代码行数:9,代码来源:APEv2Tag.cpp

示例5: BuildHistoryFileStats

void CHistoryDlg::BuildHistoryFileStats(CListCtrl* pListCtrl)
{
	m_nEntries = 0;
	m_nDeleted = 0;

	CFile theHistoryFile;
	CFileException cfe;

	if(theHistoryFile.Open("HISTORY.DAT", CFile::modeRead, &cfe) == FALSE)
	{
		TRACE("CHistoryDlg::BuildHistoryFileStats() - File Not Opened\n");
		return;
	}

	TRACE("CHistoryDlg::BuildHistoryFileStats() - Getting Status ...\n");

	CTaskObject oneTask;

	DWORD dwFilePos = 0;
	
	int nPartsTotal;
	TCHAR szParts[32];

	while(oneTask.ReadFromFile(theHistoryFile) == TRUE)
	{
		++m_nEntries;
		if (oneTask.m_nState == CTaskObject::PM_POSTING)
			oneTask.m_nState = CTaskObject::PM_QUEUED;
		else if (oneTask.m_nState == CTaskObject::PM_ENCODING)
			oneTask.m_nState = CTaskObject::PM_ENC_QUEUED;


		TRACE2("  Task %4d at Offset %u\n", m_nEntries, dwFilePos);
		
		if(oneTask.m_bHistoryDeleted)
			++m_nDeleted;
		else
		{
			if(pListCtrl != NULL)
			{
				nPartsTotal = oneTask.getNbParts();
				sprintf(szParts, "%d/%d", nPartsTotal - oneTask.m_dwaPartsToPost.GetSize(), nPartsTotal);
				pListCtrl->InsertItem(0, oneTask.m_szSubject);
				pListCtrl->SetItemText(0, 1, szParts);
				pListCtrl->SetItemText(0, 2, oneTask.m_szHistoryDateTime);
				pListCtrl->SetItemData(0, dwFilePos);
			}
		}

		dwFilePos = theHistoryFile.GetPosition();
	}

	theHistoryFile.Close();
}
开发者ID:annatar,项目名称:YencPowerPost,代码行数:54,代码来源:HistoryDlg.cpp

示例6: ContentReaderCallback

int CWebServer::ContentReaderCallback(void *cls, size_t pos, char *buf, int max)
#endif
{
  CFile *file = (CFile *)cls;
  if((unsigned int)pos != file->GetPosition())
    file->Seek(pos);
  unsigned res = file->Read(buf, max);
  if(res == 0)
    return -1;
  return res;
}
开发者ID:2BReality,项目名称:xbmc,代码行数:11,代码来源:WebServer.cpp

示例7: Write

//--------------------------------------------------------------------------------
bool CFileIndexObjMap::Write(CFile& file)
	{
	DWORD nPos;
	bool bPosOk = false;
	bool bRv = true;
	POSITION pos = GetStartPosition();

	TRY
		{
		nPos = file.GetPosition();
		bPosOk = true;
		DWORD nNum = 'CMAP';
		file.Write(&nNum, sizeof(nNum));
		nNum = GetCount();
		file.Write(&nNum, sizeof(nNum));
		}
	CATCH_ALL(e)
		{
		bRv = false;
		pos = NULL;
		}
	END_CATCH_ALL;

	while(pos != NULL)
		TRY
			{
			LPCTSTR pKey;
			CFileIndexObject* pObj;
			GetNextAssoc(pos, pKey, pObj);
			if(pObj == NULL)
				THROW(new CException);

			pObj->Write(file, false);
			}
		CATCH_ALL(e)
			{
			bRv = false;
			break;
			}
		END_CATCH_ALL;

	if(bPosOk && ! bRv)
		TRY
			{
			file.Seek(nPos, CFile::begin);
			}
		CATCH_ALL(e)
			{
			}
		END_CATCH_ALL;

	return bRv;
	}
开发者ID:moosethemooche,项目名称:Certificate-Server,代码行数:54,代码来源:FileIndexObject.cpp

示例8: Parser

int CPatch::Parser(CString &pathfile)
{
	CString str;

	CFile PatchFile;

	m_PathFile=pathfile;
	if( ! PatchFile.Open(pathfile,CFile::modeRead) )
		return -1;

#if 0
	int i=0;
	while(i<4)
	{
		PatchFile.ReadString(str);
		if(i==1)
			this->m_Author=str.Right( str.GetLength() - 6 );
		if(i==2)
			this->m_Date = str.Right( str.GetLength() - 6 );
		if(i==3)
			this->m_Subject = str.Right( str.GetLength() - 8 );

		++i;
	}

	LONGLONG offset=PatchFile.GetPosition();
#endif
	PatchFile.Read(m_Body.GetBuffer((UINT)PatchFile.GetLength()), (UINT)PatchFile.GetLength());
	m_Body.ReleaseBuffer();
	PatchFile.Close();

	int start=0;
	CStringA one;
	one=m_Body.Tokenize("\n",start);

	one=m_Body.Tokenize("\n",start);
	if(one.GetLength()>6)
		g_Git.StringAppend(&m_Author, (BYTE*)one.GetBuffer() + 6, CP_UTF8, one.GetLength() - 6);

	one=m_Body.Tokenize("\n",start);
	if(one.GetLength()>6)
		g_Git.StringAppend(&m_Date, (BYTE*)one.GetBuffer() + 6, CP_UTF8, one.GetLength() - 6);

	one=m_Body.Tokenize("\n",start);
	if(one.GetLength()>9)
		g_Git.StringAppend(&m_Subject, (BYTE*)one.GetBuffer() + 9, CP_UTF8, one.GetLength() - 9);

	//one=m_Body.Tokenize("\n",start);

	g_Git.StringAppend(&m_strBody, (BYTE*)m_Body.GetBuffer() + start + 1, CP_UTF8, m_Body.GetLength() - start - 1);

	return 0;
}
开发者ID:hfeeki,项目名称:TortoiseGit,代码行数:53,代码来源:Patch.cpp

示例9: GetFilePosition

int64_t CAddonCallbacksAddon::GetFilePosition(const void* addonData, void* file)
{
  CAddonInterfaces* helper = (CAddonInterfaces*) addonData;
  if (!helper)
    return 0;

  CFile* cfile = (CFile*)file;
  if (!cfile)
    return 0;

  return cfile->GetPosition();
}
开发者ID:anaconda,项目名称:xbmc,代码行数:12,代码来源:AddonCallbacksAddon.cpp

示例10: Read

//--------------------------------------------------------------------------------
bool CFileIndexObject::Read(CFile& file, bool bResetPosOnError)
	{
	DWORD nPos;
	bool bPosOk = false;
	DWORD nNum;
	char* pBuf = NULL;
	bool bRv = true;

	TRY
		{
		if(bResetPosOnError)
			{
			nPos = file.GetPosition();
			bPosOk = true;
			}

		// read the object id
		if(file.Read(&nNum, sizeof(nNum)) == sizeof(nNum))
			// be sure we're reading the object we want
			if(nNum == GetObjectId())
				// read the name length
				if(file.Read(&nNum, sizeof(nNum)) == sizeof(nNum))
					{
					pBuf = m_sName.GetBuffer(nNum);
					bRv = (file.Read(pBuf, nNum) == nNum);
					}
	char temp[1024];
	file.Read(temp, 1024);
		}
	CATCH_ALL(e)
		{
		bRv = false;
		}
	END_CATCH_ALL;

	if(pBuf != NULL)
		m_sName.ReleaseBuffer();

	if(bResetPosOnError && bPosOk && ! bRv)
		TRY
			{
			file.Seek(nPos, CFile::begin);
			}
		CATCH_ALL(e)
			{
			}
		END_CATCH_ALL;

	return bRv;
	}
开发者ID:moosethemooche,项目名称:Certificate-Server,代码行数:51,代码来源:FileIndexObject.cpp

示例11: 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 <= 0)
    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:68foxboris,项目名称:xbmc,代码行数:24,代码来源:CDDARipJob.cpp

示例12: GetRStrWrt

void CBlokRtf::GetRStrWrt(int iBlk, CString strFnd, CFile &inF, CFile &oF, int &curPos, CString &strOut)
{
//Указатель устанавливает за строкой поиска
//пишет в файл со строкой поиска
//возвращает считанный весь буфер в виде строки strOut
	CString strBuf,strTg,s;
	CString strWrt=_T("");
	strTg = _T("");
	int tPos;//=0;				// Позиция в strBuf
	int iCnt = 0;
	bool bEnd=true;
	strBuf = GetStrBuf(iBlk,inF,curPos,bEnd);
	if(!bEnd){
//		AfxMessageBox("False");
		return;
	}
//AfxMessageBox("Исх строка\n"+strBuf);
//AfxMessageBox("Подстрока\n"+strFnd);
//-------------------------------Ищу вхождение  подстроки
	if((tPos = strBuf.Find(strFnd))!=-1){
		strTg = strBuf.Left(tPos+strFnd.GetLength());
		iCnt = strTg.GetLength();
		strOut+=strTg;
		oF.Write(strTg,iCnt);			// Записал
//		s.Format(" Нашёл GetRStr curPos = %i",curPos);
//AfxMessageBox("Нашёл в GetRStrWrtStr \n"+s+'\n'+strTg);
		curPos+= iCnt;
		inF.Seek(curPos,CFile::begin); // поставил указатель ЗА
//			s.Format(" после нашёл Seek curPos = %i",curPos);
//		AfxMessageBox(s);
		return;
	}
	else{						// Не нашёл, можно читать дальше
		AfxMessageBox("Не нашёл GetRStrWrt\n"+strBuf);
//		AfxMessageBox("накопление\n"+strOut);
		oF.Write(strBuf,iBlk);			// Записал
		curPos+=iBlk;
		inF.Seek(curPos,CFile::begin);	// Переместил
//		inF.Seek(iBlk,CFile::current);	// Переместил
		curPos = inF.GetPosition();
		GetRStrWrt(iBlk,strFnd,inF,oF,curPos,strOut);
		return;
	}

}
开发者ID:03bekjob,项目名称:Strg,代码行数:45,代码来源:BlokRtf.cpp

示例13: GetRStr

void CBlokRtf::GetRStr(int iBlk, CString strFnd, CFile &inF, int &curPos, CString& strOut)
{
//Считывает строку по подстроке
//указатель устанавливается за стракой
//ничего НЕ пишет

	CString strBuf,strTg,s;
	strTg = _T("");
	int tPos;//=0;				// Позиция в strBuf
	int iCnt = 0;
	bool bEnd=true;
	strBuf = GetStrBuf(iBlk,inF,curPos,bEnd);
	if(!bEnd){
//		AfxMessageBox("False");
		return;
	}
//AfxMessageBox("Исх строка\n"+strBuf+'\n'+"Подстрока\n"+strFnd);
//-------------------------------Ищу вхождение  подстроки
	if((tPos = strBuf.Find(strFnd))!=-1){
		strTg = strBuf.Left(tPos+strFnd.GetLength());
//AfxMessageBox("Нашёл в GetR \n"+strTg);
		iCnt = strTg.GetLength();
		strOut+=strTg;
		s.Format(" Нашёл GetRStr curPos = %i",curPos);
AfxMessageBox("Нашёл в GetRStr \n"+s+'\n'+"strTg = "+strTg);
		curPos+= iCnt;
		inF.Seek(curPos,CFile::begin); // поставил указатель ЗА
//			s.Format(" после нашёл Seek curPos = %i",curPos);
//		AfxMessageBox(s);
		return;
	}
	else{						// Не нашёл, можно читать дальше
//		AfxMessageBox("Не нашёл GetRStr\n"+strBuf);
//		AfxMessageBox("накопление\n"+strOut);
		strOut+=strBuf;
		curPos+=iBlk;
		inF.Seek(curPos,CFile::begin);	// Переместил
//		inF.Seek(iBlk,CFile::current);	// Переместил
		curPos = inF.GetPosition();
		GetRStr(iBlk,strFnd,inF,curPos,strOut);
		return;
	}

}
开发者ID:03bekjob,项目名称:Strg,代码行数:44,代码来源:BlokRtf.cpp

示例14: GetStrWrtStr

void  CBlokRtf::GetStrWrtStr(int iBlk, CFile &inF, CFile& oF, CString strFnd, int& curPos)
{
// получение строки от тек. поз. до искомой строки
// включая саму строку поиска
// установка указателя за последним символом искомой строки
// пишет !!!

	CString strBuf=_T(""),s;

//	s.Format("до считки curPos = %i",curPos);
//	AfxMessageBox(s);
	bool bEnd=true;
	strBuf = GetStrBuf(iBlk,inF,curPos,bEnd);
//	s.Format("после считки curPos = %i",curPos);
//	AfxMessageBox(s);

	int tPos,iCnt;
	CString strTg=_T("");

	if((tPos=strBuf.Find(strFnd))!=-1){ // Нашёл
		strTg = strBuf.Left(tPos+strFnd.GetLength());
//AfxMessageBox("Нашёл в GetStrWrtStr \n"+strTg);
		iCnt = strTg.GetLength();
		oF.Write(strTg,iCnt);			// Записал
		curPos+= iCnt;
		s.Format(" Нашёл GetStrWrtStr curPos = %i",curPos);
AfxMessageBox(s+'\n'+strTg);
		inF.Seek(curPos,CFile::begin); // поставил указатель ЗА
									   // искомую строку
		return; // curPos;
	}
	else{
		oF.Write(strBuf,iBlk);					// Записал 
//		AfxMessageBox("Не нашёл GetStrWrtStr\n"+strBuf);
		curPos+=iBlk;
		inF.Seek(curPos,CFile::begin);			// Переместил
//		inF.Seek(iBlk,CFile::current);			// Переместил
		curPos = inF.GetPosition();
		GetStrWrtStr(iBlk,inF,oF,strFnd,curPos);
		return;
	}

}
开发者ID:03bekjob,项目名称:Strg,代码行数:43,代码来源:BlokRtf.cpp

示例15: SerializeRaw

void CEditView::SerializeRaw(CArchive& ar)
	// Read/Write object as stand-alone file.
{
	ASSERT_VALID(this);
	if (ar.IsStoring())
	{
		WriteToArchive(ar);
	}
	else
	{
		CFile* pFile = ar.GetFile();
		ASSERT(pFile->GetPosition() == 0);
		DWORD nFileSize = pFile->GetLength();
		if (nFileSize/sizeof(TCHAR) > nMaxSize)
		{
			AfxMessageBox(AFX_IDP_FILE_TOO_LARGE);
			AfxThrowUserException();
		}
		// ReadFromArchive takes the number of characters as argument
		ReadFromArchive(ar, (UINT)nFileSize/sizeof(TCHAR));
	}
	ASSERT_VALID(this);
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:23,代码来源:viewedit.cpp


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