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


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

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


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

示例1: CanDecode

bool JPGDecoder::CanDecode(const std::string &filename)
{
  CFile *fp = new CFile();
  bool ret = false;
  unsigned char magic[2];
  if (fp->Open(filename))
  {

    //JPEG image files begin with FF D8 and end with FF D9.
    // check for FF D8 big + little endian on start
    uint64_t readbytes = fp->Read(magic, 2);
    if (readbytes == 2)
    {
      if ((magic[0] == 0xd8 && magic[1] == 0xff) ||
          (magic[1] == 0xd8 && magic[0] == 0xff))
        ret = true;
    }

    if (ret)
    {
      ret = false;
      //check on FF D9 big + little endian on end
      uint64_t fileSize = fp->GetFileSize();
      fp->Seek(fileSize - 2);
      readbytes = fp->Read(magic, 2);
      if (readbytes == 2)
      {
        if ((magic[0] == 0xd9 && magic[1] == 0xff) ||
           (magic[1] == 0xd9 && magic[0] == 0xff))
          ret = true;
      }
    }
  }
  delete fp;
  return ret;
}
开发者ID:FLyrfors,项目名称:xbmc,代码行数:36,代码来源:JPGDecoder.cpp

示例2: loadMap

/////////////////////////////////////////////////////////////////////////////
// load a map from the database into the current map file
/////////////////////////////////////////////////////////////////////////////
void CMapDatabase::loadMap(int iMap)
{
	CFile file;

	//open the database file
	if(!file.Open(FILE_MAP, CFile::modeRead)) 
	{
		return;
	}

	//seek to this position in the game file
	file.Seek(m_dwOffsets[iMap], CFile::begin);
	CArchive ar(&file, CArchive::load);

	//load the file version
	ar >> m_fVer;
	
	//read the game data
	m_Map.Serialize(ar);

	//cleanup
	ar.Close();
	file.Close();
}
开发者ID:saladyears,项目名称:Sea3D,代码行数:27,代码来源:MapDatabase.cpp

示例3: BMReadWeaponInfoD1

void BMReadWeaponInfoD1 (CFile& cf)
{
cf.Seek (
	sizeof (int) +
	sizeof (int) +
	sizeof (tBitmapIndex) * D1_MAX_TEXTURES +
	sizeof (D1_tmap_info) * D1_MAX_TEXTURES +
	sizeof (ubyte) * D1_MAX_SOUNDS +
	sizeof (ubyte) * D1_MAX_SOUNDS +
	sizeof (int) +
	sizeof (tVideoClip) * D1_VCLIP_MAXNUM +
	sizeof (int) +
	sizeof (D1_eclip) * D1_MAX_EFFECTS +
	sizeof (int) +
	sizeof (tD1WallClip) * D1_MAX_WALL_ANIMS +
	sizeof (int) +
	sizeof (D1Robot_info) * D1_MAX_ROBOT_TYPES +
	sizeof (int) +
	sizeof (tJointPos) * D1_MAX_ROBOT_JOINTS,
	SEEK_CUR);
gameData.weapons.nTypes [1] = cf.ReadInt ();
for (int i = 0; i < gameData.weapons.nTypes [1]; i++)
	BMReadWeaponInfoD1N (cf, i);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:24,代码来源:loadgamedata.cpp

示例4: A_weight

/*A_weight*/
float A_weight(float xin[],int N,int fs)
{	
//-----------------------------
	char* lpszFileName;
	CFile aweight;
	CFileException fileException;
	//-----------------------------
	lpszFileName = "C:\\Program Files\\Evndaq\\AWeightdata.dat";/**/
	aweight.Open(lpszFileName,CFile::modeRead | CFile::typeBinary, &fileException);
//------------------------------------------
	FFT(xin,N);
	float p00 = (float)2e-5;
	int fp;
	float aw;
	float av = 0;
	float tem;
	for (int d = 0; d < N/2; d++)
	{	
		if (xin[d] == 0)
		{
			xin[d] = (float)2e-5;
		}
		tem = xin[d];
		xin[d]=20*log10(tem/p00);
		fp = d*fs/N;
		aweight.Seek(2*fp*sizeof(float),CFile::begin);
		aweight.Read((void*)&aw,sizeof(float));
		xin[d] =xin[d] + aw;
		av += pow(10,0.1*xin[d]);

	}
	av = 10*log10(av)-14;//修正14db
	aweight.Close();
	return av;

}
开发者ID:brygid,项目名称:signalProcess,代码行数:37,代码来源:mathcal.cpp

示例5: Load

	void Load() {
		if (!CFile::Exists(GetConfigPath())) {
			DEBUG("ignore: Config file doesn't exist");
			return;
		}

		if (!CFile::IsReg(GetConfigPath())) {
			DEBUG("ignore: Config file isn't a file");
			return;
		}

		CFile *pFile = new CFile(GetConfigPath());
		if (!pFile->Open(GetConfigPath(), O_RDONLY)) {
			DEBUG("ignore: Error opening config file");
			delete pFile;
			return;
		}

		if (!pFile->Seek(0)) {
			DEBUG("ignore: Error, can't seek to start of config file.");
			delete pFile;
			return;
		}

		m_vIgnores.clear();

		CString sLine;

		while (pFile->ReadLine(sLine)) {
			sLine.TrimLeft();
			sLine.TrimRight("\n");

			CIgnore Ignore = CIgnore(sLine);
			m_vIgnores.push_back(Ignore);
		}
	}
开发者ID:JeremiahDJordan,项目名称:znc-contrib,代码行数:36,代码来源:ignore.cpp

示例6: ReadBotGenInfo

static int ReadBotGenInfo (CFile& cf)
{
if (gameFileInfo.botGen.offset > -1) {
	int	i, j;

	if (cf.Seek (gameFileInfo.botGen.offset, SEEK_SET)) {
		Error ("Error seeking to robot generator data\n(file damaged or invalid)");
		return -1;
		}
	for (i = 0; i < gameFileInfo.botGen.count; i++) {
		if (gameTopFileInfo.fileinfoVersion < 27) {
			old_tMatCenInfo m;

			OldMatCenInfoRead (&m, cf);

			gameData.matCens.botGens [i].objFlags [0] = m.objFlags;
			gameData.matCens.botGens [i].objFlags [1] = 0;
			gameData.matCens.botGens [i].xHitPoints = m.xHitPoints;
			gameData.matCens.botGens [i].xInterval = m.xInterval;
			gameData.matCens.botGens [i].nSegment = m.nSegment;
			gameData.matCens.botGens [i].nFuelCen = m.nFuelCen;
		}
		else
			MatCenInfoRead (gameData.matCens.botGens + i, cf);

		//	Set links in gameData.matCens.botGens to gameData.matCens.fuelCenters array
		for (j = 0; j <= gameData.segs.nLastSegment; j++)
			if ((SEGMENTS [j].m_nType == SEGMENT_IS_ROBOTMAKER) &&
					(SEGMENTS [j].m_nMatCen == i)) {
				gameData.matCens.botGens [i].nFuelCen = SEGMENTS [j].m_value;
				break;
				}
		}
	}
return 0;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:36,代码来源:gamesave.cpp

示例7: OtherFilestoDecode

int KiesBNR::OtherFilestoDecode(char* inputPath, char* outputPath, char* fileName){
	//Read Input File
	CString inputPathString = (CString)inputPath;
	if(!PathFileExists((LPCWSTR)inputPathString))
		return 0;

	UINT XMLDataOffset = 0;

	CFile input;
	if ( !input.Open((LPCWSTR)inputPathString, CFile::modeRead | CFile::modeNoTruncate | CFile::typeBinary) )
	{
		return false;
	}

	//XML 데이터 크기만큼의 버퍼 생성;
	int nBufSize = input.GetLength();
	char* XMLData = new char[nBufSize+1];
	ZeroMemory(XMLData, nBufSize+1);

	//버퍼에 XML 내용을 읽어들인다.;
	input.Seek(XMLDataOffset, input.begin);
	input.Read(XMLData, nBufSize+1);

	//XML 데이터가 NULL일경우 False 반환;
	if (XMLData == NULL) 
		return false;  

	//메모리상에 있는 XML 데이터를 오픈 (Parse);
	TiXmlDocument m_Document;
	m_Document.Parse(XMLData);	// xml open

	// 루트노드 접근.;
	TiXmlElement* pRoot = m_Document.FirstChildElement("MtpUtilItems"); 
	if (!pRoot) 
		goto END_PROCESS;

	// 값을 읽고자 하는 Welcome 엘리먼트로 접근.;
	TiXmlElement* pElem = pRoot->FirstChildElement("Items")->FirstChildElement();

	if (!pElem) 
		goto END_PROCESS;

	while(pElem)
	{
		CString str1=_T("");
		CString element=_T("");
		DWORD str_Len = 0;
		TCHAR * dstTCHAR = NULL;

		char *psNode = (char*)pElem->Value();

		str_Len = MultiByteToWideChar(CP_ACP, 0, psNode, strlen(psNode), NULL, NULL);
		dstTCHAR = new TCHAR[str_Len + 1];
		memset(dstTCHAR, 0x00, str_Len * 2 + 2);

		MultiByteToWideChar(CP_ACP, 0, psNode, strlen(psNode), dstTCHAR, str_Len);
		element.Format(L"%s",dstTCHAR);
		delete [] dstTCHAR;


		if(element.Find(L"MtpUtilItem")!=-1)
		{
			TiXmlElement* pElem_1=pElem->FirstChildElement();

			while(pElem_1)
			{
				CString str_1=_T("");
				CString element_1=_T("");
				DWORD str_Len_1 = 0;
				TCHAR * dstTCHAR_1 = NULL;

				char *psNode_1 = (char*)pElem_1->Value();

				str_Len = MultiByteToWideChar(CP_ACP, 0, psNode_1, strlen(psNode_1), NULL, NULL);
				dstTCHAR_1 = new TCHAR[str_Len + 1];
				memset(dstTCHAR_1, 0x00, str_Len * 2 + 2);

				MultiByteToWideChar(CP_ACP, 0, psNode_1, strlen(psNode_1), dstTCHAR_1, str_Len);
				element_1.Format(L"%s",dstTCHAR_1);
				delete [] dstTCHAR_1;

				if(element_1.Find(_T("FileContent"))!= -1){
					TCHAR* dstTch = NULL;
					const char *text = pElem_1->GetText();

					if(text == NULL)
						break;

					str_Len = MultiByteToWideChar(CP_ACP, 0, text, strlen(text), NULL, NULL);
					dstTch = new TCHAR[str_Len + 1];
					memset(dstTch, 0x00, str_Len * 2 + 2);

					MultiByteToWideChar(CP_ACP, 0, text, strlen(text), dstTch, str_Len);

					str1.Format((L"%s"),dstTch);
					delete [] dstTch;
					//base64 Decoding
					string cipher(text);
					PBYTE buf_cipher = (PBYTE)malloc(cipher.size()+1);
					buf_cipher[cipher.size()] = 0x00;
//.........这里部分代码省略.........
开发者ID:JaehyeokHan,项目名称:Smartphone-Backup-Data-Extractor,代码行数:101,代码来源:KiesBNR.cpp

示例8: SMemoFiletoDecode

int KiesBNR::SMemoFiletoDecode(char* inputPath, char* outputPath){
	CString inputPathString = (CString)inputPath;
	if(!PathFileExists((LPCWSTR)inputPathString))
		return 0;

	UINT XMLDataOffset = 0;

	CFile input;
	if ( !input.Open((LPCWSTR)inputPathString, CFile::modeRead | CFile::modeNoTruncate | CFile::typeBinary) )
	{
		return false;
	}

	//XML 데이터 크기만큼의 버퍼 생성;
	int nBufSize = input.GetLength();
	char* XMLData = new char[nBufSize+1];
	ZeroMemory(XMLData, nBufSize+1);
	
	//버퍼에 XML 내용을 읽어들인다.;
	input.Seek(XMLDataOffset, input.begin);
	input.Read(XMLData, nBufSize+1);

	//XML 데이터가 NULL일경우 False 반환;
	if (XMLData == NULL) 
		return false;  

	//메모리상에 있는 XML 데이터를 오픈 (Parse);
	TiXmlDocument m_Document;
	m_Document.Parse(XMLData);	// xml open

	// 루트노드 접근.;
	TiXmlElement* pRoot = m_Document.FirstChildElement("SMemoItems"); 
	if (!pRoot) 
		goto END_PROCESS;

	// 값을 읽고자 하는 Welcome 엘리먼트로 접근.;
	TiXmlElement* pElem = pRoot->FirstChildElement("Items")->FirstChildElement();
	
	if (!pElem) 
		goto END_PROCESS;

	while(pElem)
	{
		CString str1 = _T("");
		CString str2 = _T("");
		CString str3 = _T("");
		CString str4 = _T("");
		CString element = _T("");
		DWORD str_Len = 0;
		TCHAR * dstTCHAR = NULL;

		char *psNode = (char*)pElem->Value();

		str_Len = MultiByteToWideChar(CP_ACP, 0, psNode, strlen(psNode), NULL, NULL);
		dstTCHAR = new TCHAR[str_Len + 1];
		memset(dstTCHAR, 0x00, str_Len * 2 + 2);

		MultiByteToWideChar(CP_ACP, 0, psNode, strlen(psNode), dstTCHAR, str_Len);
		element.Format(L"%s",dstTCHAR);
		delete [] dstTCHAR;


		if(element.Find(L"SMemoItem")!=-1)//SMemoItem이 들어옴..
		{
			TiXmlElement* pElem_1=pElem->FirstChildElement();

			while(pElem_1)
			{
				CString str_1=_T("");
				CString element_1=_T("");
				DWORD str_Len_1 = 0;
				TCHAR * dstTCHAR_1 = NULL;

				char *psNode_1 = (char*)pElem_1->Value();

				str_Len = MultiByteToWideChar(CP_ACP, 0, psNode_1, strlen(psNode_1), NULL, NULL);
				dstTCHAR_1 = new TCHAR[str_Len + 1];
				memset(dstTCHAR_1, 0x00, str_Len * 2 + 2);

				MultiByteToWideChar(CP_ACP, 0, psNode_1, strlen(psNode_1), dstTCHAR_1, str_Len);
				element_1.Format(L"%s",dstTCHAR_1);
				delete [] dstTCHAR_1;

				if(element_1.Find(_T("RecordID"))!= -1){
					TCHAR* dstTch1 = NULL;
					const char *text = pElem_1->GetText();

					if(text == NULL)
						break;

					str_Len = MultiByteToWideChar(CP_ACP, 0, text, strlen(text), NULL, NULL);
					dstTch1 = new TCHAR[str_Len + 1];
					memset(dstTch1, 0x00, str_Len * 2 + 2);

					MultiByteToWideChar(CP_ACP, 0, text, strlen(text), dstTch1, str_Len);

					str1.Format((L"%s"),dstTch1);
					delete [] dstTch1;
				}else if(element_1.Find(_T("CreateDate"))!= -1){
					TCHAR* dstTch2 = NULL;
//.........这里部分代码省略.........
开发者ID:JaehyeokHan,项目名称:Smartphone-Backup-Data-Extractor,代码行数:101,代码来源:KiesBNR.cpp

示例9: MessageFiletoDecode

int KiesBNR::MessageFiletoDecode(char* inputPath, char* outputPath){
	//Read Input File
	CString inputPathString = (CString)inputPath;
	if(!PathFileExists((LPCWSTR)inputPathString))
		return 0;

	UINT XMLDataOffset = 0;

	CFile input;
	if ( !input.Open((LPCWSTR)inputPathString, CFile::modeRead | CFile::modeNoTruncate | CFile::typeBinary) )
	{
		return false;
	}

	//XML 데이터 크기만큼의 버퍼 생성;
	int nBufSize = input.GetLength();
	char* XMLData = new char[nBufSize+1];
	ZeroMemory(XMLData, nBufSize+1);

	//버퍼에 XML 내용을 읽어들인다.;
	input.Seek(XMLDataOffset, input.begin);
	input.Read(XMLData, nBufSize+1);

	//XML 데이터가 NULL일경우 False 반환;
	if (XMLData == NULL) 
		return false;  

	//메모리상에 있는 XML 데이터를 오픈 (Parse);
	TiXmlDocument m_Document;
	m_Document.Parse(XMLData);	// xml open

	// 루트노드 접근.;
	TiXmlElement* pRoot = m_Document.FirstChildElement("MessageData"); 
	if (!pRoot) 
		goto END_PROCESS;

	// 값을 읽고자 하는 Welcome 엘리먼트로 접근.;
	TiXmlElement* pElem  = pRoot->FirstChildElement("SMSList")->FirstChildElement();
	TiXmlElement* pElem2 = pRoot->FirstChildElement("MMSList")->FirstChildElement();//HextoString

	if (!pElem) 
		goto END_PROCESS;

	while(pElem)
	{
		CString str1=_T("");
		CString str2=_T("");
		CString str3=_T("");
		CString str4=_T("");
		CString element=_T("");
		DWORD str_Len = 0;
		TCHAR * dstTCHAR = NULL;

		char *psNode = (char*)pElem->Value();

		str_Len = MultiByteToWideChar(CP_ACP, 0, psNode, strlen(psNode), NULL, NULL);
		dstTCHAR = new TCHAR[str_Len + 1];
		memset(dstTCHAR, 0x00, str_Len * 2 + 2);

		MultiByteToWideChar(CP_ACP, 0, psNode, strlen(psNode), dstTCHAR, str_Len);
		element.Format(L"%s",dstTCHAR);
		delete [] dstTCHAR;


		if(element.Find(L"SMSStoreItem") != -1)
		{
			TiXmlElement* pElem_1=pElem->FirstChildElement();

			//pElem1=pElem1->FirstChildElement();
			while(pElem_1)
			{
				CString str_1	   = _T("");
				CString element_1  = _T("");
				DWORD str_Len_1    = 0;
				TCHAR * dstTCHAR_1 = NULL;
				//	test.Format(L"%s", pElem->GetText()); 

				char *psNode_1 = (char*)pElem_1->Value();

				str_Len = MultiByteToWideChar(CP_ACP, 0, psNode_1, strlen(psNode_1), NULL, NULL);
				dstTCHAR_1 = new TCHAR[str_Len + 1];
				memset(dstTCHAR_1, 0x00, str_Len * 2 + 2);

				MultiByteToWideChar(CP_ACP, 0, psNode_1, strlen(psNode_1), dstTCHAR_1, str_Len);
				element_1.Format(L"%s",dstTCHAR_1);
				delete [] dstTCHAR_1;

				// CreateDate
				if(element_1.Find(_T("CreateDate"))!= -1) {
					TCHAR* dstTch = NULL;
					const char *text = pElem_1->GetText();

					if(text != NULL) {
						
						str_Len = MultiByteToWideChar(CP_ACP, 0, text, strlen(text), NULL, NULL);
						dstTch = new TCHAR[str_Len + 1];
						memset(dstTch, 0x00, str_Len * 2 + 2);

						MultiByteToWideChar(CP_ACP, 0, text, strlen(text), dstTch, str_Len);

//.........这里部分代码省略.........
开发者ID:JaehyeokHan,项目名称:Smartphone-Backup-Data-Extractor,代码行数:101,代码来源:KiesBNR.cpp

示例10: Read

int CFace::Read (CFile& cf, CSubModel *pso, CFaceVert *pfv, int bFlipV)
{
	int	i, v0 = 0;
	CEdge	e;

nIndent += 2;
OOF_PrintLog ("reading face\n");
OOF_ReadVector (cf, &m_vNormal, "vNormal");
#if 0
m_vNormal.x = -m_vNormal.x;
m_vNormal.y = -m_vNormal.y;
m_vNormal.z = -m_vNormal.z;
#endif
m_nVerts = OOF_ReadInt (cf, "nVerts");
m_bTextured = OOF_ReadInt (cf, "bTextured");
if (m_bTextured) {
	m_texProps.nTexId = OOF_ReadInt (cf, "texProps.nTexId");
#if OOF_TEST_CUBE
/*!!!*/	m_texProps.nTexId = nTexId % 6;
/*!!!*/	nTexId++;
#endif
	}
else {
	m_texProps.color.red = OOF_ReadByte (cf, "texProps.color.red");
	m_texProps.color.green = OOF_ReadByte (cf, "texProps.color.green");
	m_texProps.color.blue = OOF_ReadByte (cf, "texProps.color.blue");
	}
#if OOF_MEM_OPT
if (pfv) {
	m_verts = pfv;
#else
	if (!(m_verts= new CFaceVert [m_nVerts])) {
		nIndent -= 2;
		return OOF_FreeFace (&f);
		}
#endif
	OOF_InitMinMax (&m_vMin, &m_vMax);
	e.m_v1 [0] = -1;
	for (i = 0; i < m_nVerts; i++)
		if (!m_verts [i].Read (cf, bFlipV)) {
			nIndent -= 2;
			return 0;
			}
		else {
			e.m_v0 [0] = e.m_v1 [0];
			e.m_v1 [0] = m_verts [i].m_nIndex;
			OOF_GetMinMax (pso->m_verts + e.m_v1 [0], &m_vMin, &m_vMax);
			if (i)
				pso->AddEdge (this, e.m_v0 [0], e.m_v1 [0]);
			else
				v0 = e.m_v1 [0];
			}
	pso->AddEdge (this, e.m_v1 [0], v0);
	CalcCenter (pso);
#if OOF_MEM_OPT
	}
else
	cf.Seek (m_nVerts * sizeof (CFaceVert), SEEK_CUR);
#endif
m_fBoundingLength = OOF_ReadFloat (cf, "fBoundingLength");
m_fBoundingWidth = OOF_ReadFloat (cf, "fBoundingWidth");
nIndent -= 2;
return m_nVerts;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:64,代码来源:oofread.cpp

示例11: dlg


//.........这里部分代码省略.........

	if(m_wBitPerSample != BITS_PER_SAMPLE_8)
	{
		return FALSE;
	}

	// fill in the low 8 bits data
	for(DWORD u = 0; u < dwLength / 2; u++)
	{
		memcpy(lpData + u * 2 + 1, m_lpData + u, sizeof(BYTE));
		
		if((lpData[u * 2 + 1] & 0x80) == 0x80)
		{
			lpData[u * 2 + 1] &= 0x7f;
		}
		else
		{
			lpData[u * 2 + 1] |= 0x80;
		}
		
		lpData[u * 2] = 0x00;
	}
	
	// save it as a new wav file
	CFileDialog dlg(FALSE, NULL, _T("*.wav"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
		_T("WAV Files (*.wav)|*.wav||"));
	
	if(dlg.DoModal() == IDOK)
	{
		CFile fileNew;
		FILE  *fileOld = NULL;			
		LPCTSTR lpszFilePath = m_strWavePath;
		
		fileOld = fopen(lpszFilePath, "rb");
		BOOL bOpen = fileNew.Open(dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate);
		
		if(fileOld != NULL && bOpen)
		{
			_RIFFCHUNK RiffChunk;
			_WAVEFORMAT WaveFormat;
			
			// read RIFF WAVE chunk and format chunk
			fread(&RiffChunk, sizeof(_RIFFCHUNK), 1, fileOld);
			fread(&WaveFormat, sizeof(_WAVEFORMAT), 1, fileOld);
			
			// write RIFF WAVE chunk
			fileNew.Write(&RiffChunk, sizeof(_RIFFCHUNK));
			
			WaveFormat.wBlockAlign *= 2; 
			WaveFormat.dwAvgBytesPerSec *= 2;
			WaveFormat.wBitsPerSample = BITS_PER_SAMPLE_16;
			
			fileNew.Write(&WaveFormat, sizeof(_WAVEFORMAT));
			
			// read next chunk
			BYTE  byId[4];
			DWORD dwSize = 0;
			fread(byId, sizeof(BYTE), 4, fileOld);
			fread(&dwSize, sizeof(DWORD), 1, fileOld);
			DWORD dwOffset = ftell(fileOld);
			LPBYTE lpTemp = (LPBYTE)malloc(m_RiffChunk.dwSize * sizeof(BYTE));
			
			while(dwOffset < m_RiffChunk.dwSize)
			{
				// see if the data chunk or not
				if(strncmp((LPCSTR)byId, "data", 4) == 0)
				{
					fread(lpTemp, sizeof(BYTE), dwSize, fileOld);
					fileNew.Write(&byId, sizeof(DWORD));
					fileNew.Write(&dwLength, sizeof(DWORD));
					fileNew.Write(lpData, sizeof(BYTE) * dwLength);
				}
				
				// other chunks just copy them
				else
				{
					fread(lpTemp, sizeof(BYTE), dwSize, fileOld);
					fileNew.Write(&byId, sizeof(DWORD));
					fileNew.Write(&dwSize, sizeof(DWORD));
					fileNew.Write(lpTemp, sizeof(BYTE) * dwSize);
				}
				
				// continue to read next chunk
				fread(byId, sizeof(BYTE), 4, fileOld);
				fread(&dwSize, sizeof(DWORD), 1, fileOld);
				dwOffset = ftell(fileOld);
			}
			free(lpTemp);
			
			// adjust the size of RIFF
			DWORD dwRiffSize = RiffChunk.dwSize + dwLength / 2;
			fileNew.Seek(4, CFile::begin);
			fileNew.Write(&dwRiffSize, sizeof(DWORD));
			
			fclose(fileOld);
			fileNew.Close();
		}	
	}
	return TRUE;	
}
开发者ID:ningmenglive,项目名称:NineLine,代码行数:101,代码来源:WavFile.cpp

示例12: Readfile

LONG CRectangle::Readfile(CFile &file)
{
	 file.Seek(sizeof(TP),CFile::current);
	 return CLine::Readfile(file);
}
开发者ID:sergedeh,项目名称:andycad,代码行数:5,代码来源:rectangle.cpp

示例13: sizeof

hmp_file *hmp_open(const char *filename, int bUseD1Hog) 
{
	int i;
	char buf [256];
	long data = 0;
	CFile cf;
	hmp_file *hmp;
	int num_tracks, midi_div;
	ubyte *p;

	if (!cf.Open (filename, gameFolders.szDataDir, "rb", bUseD1Hog))
		return NULL;
	hmp = new hmp_file;
	if (!hmp) {
		cf.Close();
		return NULL;
	}
	memset(hmp, 0, sizeof(*hmp));
	if ((cf.Read (buf, 1, 8) != 8) || (memcmp(buf, "HMIMIDIP", 8)))
		goto err;
	if (cf.Seek (0x30, SEEK_SET))
		goto err;
	if (cf.Read (&num_tracks, 4, 1) != 1)
		goto err;
	if (cf.Seek (0x38, SEEK_SET))
		goto err;
	if (cf.Read (&midi_div, 4, 1) != 1)
		goto err;
	if ((num_tracks < 1) || (num_tracks > HMP_TRACKS))
		goto err;
	hmp->num_trks = num_tracks;
	hmp->midi_division = midi_div;
   hmp->tempo = 120;
	if (cf.Seek(0x308, SEEK_SET))
		goto err;
    for (i = 0; i < num_tracks; i++) {
		if ((cf.Seek(4, SEEK_CUR)) || (cf.Read(&data, 4, 1) != 1))
			goto err;
		data -= 12;
#if 0
		if (i == 0)  /* track 0: reserve length for tempo */
		    data += sizeof(hmp_tempo);
#endif
		hmp->trks [i].len = data;
		if (!(p = hmp->trks [i].data = new ubyte [data]))
			goto err;
#if 0
		if (i == 0) { /* track 0: add tempo */
			memcpy(p, hmp_tempo, sizeof(hmp_tempo));
			p += sizeof(hmp_tempo);
			data -= sizeof(hmp_tempo);
		}
#endif
					     /* finally, read track data */
		if ((cf.Seek(4, SEEK_CUR)) || (cf.Read(p, data, 1) != 1))
            goto err;
   }
   cf.Close();
   return hmp;

err:
   cf.Close();
   hmp_close(hmp);
   return NULL;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:65,代码来源:hmpfile.cpp

示例14: ASSERT

 CFile cfile;
 cfile.Open(_T("Seek_File.dat"), CFile::modeCreate |
    CFile::modeReadWrite);
 LONGLONG lOffset = 1000;
 ULONGLONG lActual;
 lActual = cfile.Seek(lOffset, CFile::begin);
 ASSERT(cfile.GetPosition() == lActual);
开发者ID:terryjintry,项目名称:OLSource1,代码行数:7,代码来源:cfile-class_5.cpp

示例15: file

bool    External::Goto_Chunks_Header(    CFile&  file,    short  chunkCode,   unsigned char&  retVersion,
																		                           long&  retChunksSize,   CString&  retErrorMesg  )
{

				// ****   want  OPTIMIZE search    9/06  ???    **********************


	CString   retTagString;
	long       curPos =  0L;  // ****** Always starts from the BEGINNING of the file. Is that good???  It is thourough.  9/06 ****


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



	long  filesLength =   file.GetLength();

	file.Seek(   curPos,    CFile::begin   );  // ***** BAD,  only occasionally search from beginning ******



	bool   stringNotFound =   true;

	CString    travStr =  "        ";   // cheezy way to put a NULL terminator in the string


	do			
	{  file.Read(   travStr.GetBuffer( 8 ),    8   );


		if(     retTagString.CompareNoCase(  travStr  )  ==   0     )
			stringNotFound =   false;
		else
		{  curPos++;

			if(    (curPos  +  8)   >=   filesLength    )    //   check for EOF  
			{
				retErrorMesg.Format(   "External::Goto_Chunks_Header FAILED,  could not find tag's string [ %s ] in the file( hit eof )." ,    retTagString  );
				return  false;
			}


			file.Seek(   curPos,    CFile::begin   );  
		}

	}while(  stringNotFound  );




	file.Read(   &retVersion,          1  ); 

	file.Read(   &retChunksSize,    4  );



//	long   curFilePos  =     file.GetPosition();   //   ...want to return this ???   **** DEBUG ONLY ****


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


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