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


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

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


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

示例1: drawPicture

void CMyDrawPictureClass::drawPicture()
{	
	this->UpdateData();
	CString offsetColorStr=_T("0");
	DWORD lowColor=0;
	this->GetDlgItem(IDC_EDIT_OffsetColor1)->GetWindowTextW(offsetColorStr);
	lowColor = ::wcstol(offsetColorStr,0,16);
	BYTE offr,offg,offb;
	offr = GetRValue(lowColor);
	offg = GetGValue(lowColor);
	offb = GetBValue(lowColor);


	CRect rctWindowSize,rctTargetPic;
	m_LoadSourcePic.GetWindowRect(rctWindowSize);

	this->GetDlgItem(IDC_STATIC_TARGET)->GetWindowRect(&rctTargetPic);

	//CClientDC cDC(this);
	HDC hScrDC,hMemDC;
	////为屏幕创建设备描述表
	hScrDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
	//为屏幕设备描述表创建兼容的内存设备描述表
	hMemDC = CreateCompatibleDC(hScrDC);
	//////////////////创建一个原图大小的位图//////////////////////
	HBITMAP hBitmap = ::CreateCompatibleBitmap(hScrDC,m_Width,this->m_Height);
	HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC,hBitmap);
	BitBlt(hMemDC, 0, 0, m_Width,m_Height,hScrDC, rctWindowSize.left, rctWindowSize.top, CAPTUREBLT|SRCCOPY);
	hBitmap = (HBITMAP)SelectObject(hMemDC,hOldBitmap);

	// 24位图的BITMAPINFO
    BITMAPINFO *pBITMAPINFO = (BITMAPINFO*)malloc(sizeof(BITMAPINFOHEADER));
    memset(pBITMAPINFO, 0, sizeof(BITMAPINFOHEADER));
    BITMAPINFOHEADER *pInfo_Header = (BITMAPINFOHEADER *)pBITMAPINFO;
    pInfo_Header->biSize = sizeof(BITMAPINFOHEADER);   
    pInfo_Header->biWidth = m_Width;   
    pInfo_Header->biHeight = m_Height;   
    pInfo_Header->biPlanes = 1;   
    pInfo_Header->biBitCount = 24;   
    pInfo_Header->biCompression = BI_RGB;
	
	 // 获得数据buf
    DWORD bufSize = (pInfo_Header->biWidth * 3 + 3) / 4 * 4 * pInfo_Header->biHeight;
    BYTE * pBuffer = new BYTE[bufSize];

	int aHeight=pInfo_Header->biHeight;

    if(::GetDIBits(hMemDC, hBitmap, 0, aHeight, pBuffer,pBITMAPINFO, DIB_RGB_COLORS) == 0)
    {
       return ;
    }

	BYTE fr,fg,fb,lr,lg,lb;
	fr = GetRValue(m_ForegroundColor);
	fg = GetGValue(m_ForegroundColor);
	fb = GetBValue(m_ForegroundColor);

	lr = GetRValue(m_LowColor);
	lg = GetGValue(m_LowColor);
	lb = GetBValue(m_LowColor);

	int pitch=m_Width%4;
	for(int i=0;i<m_Height;i++)
	{
		int realPitch=i*pitch;
		for(int j=0;j<m_Width;j++)
		{
			UCHAR b=pBuffer[(i*m_Width+j)*3+realPitch];
			UCHAR g=pBuffer[(i*m_Width+j)*3+1+realPitch];
			UCHAR r=pBuffer[(i*m_Width+j)*3+2+realPitch];
			//helpcolor=RGB(r,g,b);
			if(abs(r-fr)<=offr&&abs(g-fg)<=offg&&abs(b-fb)<=offb)
			{
				continue;
			}
			else
			{
				pBuffer[(i*m_Width+j)*3+realPitch] = lb;
				pBuffer[(i*m_Width+j)*3+1+realPitch] = lg;
				pBuffer[(i*m_Width+j)*3+2+realPitch] = lr;
			}

		}
	}


	//保存到文件并创建位图结构
	BITMAPFILEHEADER bmfh;
	ZeroMemory(&bmfh,sizeof(BITMAPFILEHEADER));

	*((char*)&bmfh.bfType) = 'B';
	*(((char*)&bmfh.bfType) + 1) = 'M';

	bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
	bmfh.bfSize = bmfh.bfOffBits + (m_Width * m_Height) * pInfo_Header->biBitCount / 8;
	CFile file;
	if(file.Open(g_CurrentExePath+_T("TCTEMP.bmp"),CFile::modeWrite|CFile::modeCreate))
	{
		file.Write(&bmfh,sizeof(BITMAPFILEHEADER));
		file.Write(&(pBITMAPINFO->bmiHeader),sizeof(BITMAPINFOHEADER));
//.........这里部分代码省略.........
开发者ID:JohnWilliam1988,项目名称:AB,代码行数:101,代码来源:MyDrawPictureClass.cpp

示例2: 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

示例3: SaveToFile

BOOL CModbusM::SaveToFile(CString strFile)
{
	CString strBuf,str;
	str.Format("PORT=%d\r\n",PORT);
	strBuf+=str;
	str.Format("BAUDRATE=%d\r\n",BAUDRATE);
	strBuf+=str;
	str.Format("STOPBITS=%d\r\n",STOPBITS);
	strBuf+=str;
	str.Format("PARITY=%d\r\n",PARITY);
	strBuf+=str;
	str.Format("BYTETIME=%d\r\n",BYTETIME);
	strBuf+=str;
	str.Format("WAITRESP=%d\r\n",WAITRESP);
	strBuf+=str;
	str.Format("NEXTMESSAGE=%d\r\n",NEXTMESSAGE);
	strBuf+=str;
	str.Format("NUMBER_OF_PRIBOR=%d\r\n",m_ModbusPriborArray.GetSize());
	strBuf+=str;
	str.Format("AMOUNTBYTE=%d\r\n",AMOUNTBYTE);
	strBuf+=str;
	str.Format("CONTROLPOTOK=%d\r\n",CONTROLPOTOK);
	strBuf+=str;
	str.Format("NUMBER_NO_ANSWER=%d\r\n",NUMBER_NO_ANSWER);
	strBuf+=str;
	str.Format("MODBUS_TYPE=%d\r\n\r\n",MODBUS_TYPE);
	strBuf+=str;	
	
	for(int i =0; i < m_ModbusPriborArray.GetSize(); i++)
	{
		str.Format("MAKE_PRIBOR=%d\r\n",i+1);
		strBuf+=str;		
		str.Format("PRIBOR=%d\r\n",m_ModbusPriborArray[i].PRIBOR);
		strBuf+=str;
		str.Format("ADRESS=%d\r\n",m_ModbusPriborArray[i].ADRESS);
		strBuf+=str;		
		str.Format("FUNCTION=%d\r\n",m_ModbusPriborArray[i].FUNCTION);
		strBuf+=str;
		str.Format("START_ADRESS=%d\r\n",m_ModbusPriborArray[i].START_ADRESS);
		strBuf+=str;
		str.Format("NUMBER=%d\r\n",m_ModbusPriborArray[i].NUMBER);
		strBuf+=str;
		str.Format("ADRESS_PMZ=%d\r\n",m_ModbusPriborArray[i].ADRESS_PMZ);
		strBuf+=str;
		str.Format("DOP_BYTE1=%d\r\n",m_ModbusPriborArray[i].DOP_BYTE1);
		strBuf+=str;
		str.Format("DOP_BYTE2=%d\r\n",m_ModbusPriborArray[i].DOP_BYTE2);
		strBuf+=str;
		str.Format("DOP_BYTE3=%d\r\n",m_ModbusPriborArray[i].DOP_BYTE3);
		strBuf+=str;
		str.Format("DOP_BYTE4=%d\r\n",m_ModbusPriborArray[i].DOP_BYTE4);
		strBuf+=str;
		str.Format("TYPE_STATUS=%d\r\n",m_ModbusPriborArray[i].TYPE_STATUS);
		strBuf+=str;
		str.Format("MASKA_STATUS=%d\r\n",m_ModbusPriborArray[i].MASKA_STATUS);
		strBuf+=str;
		str.Format("ADRES_STATUS=%d\r\n",m_ModbusPriborArray[i].ADRES_STATUS);
		strBuf+=str;
		str.Format("ADRES_4B=%d\r\n",m_ModbusPriborArray[i].ADRES_4B);
		strBuf+=str;
		str.Format("//%s\r\n\r\n",m_ModbusPriborArray[i].strCOMMENT);
		strBuf+=str;
	}
	
	CFile f;
	try
	{
		f.Open(strFile,CFile::modeCreate|CFile::modeWrite);
		f.Write((void*)strBuf.GetBuffer(),strBuf.GetLength());
		f.Close();		
	}
	catch(...)
	{
		return FALSE;
	}
	return TRUE;
}
开发者ID:toschkin,项目名称:KPL,代码行数:77,代码来源:ModbusM.cpp

示例4: OnInitDialog

/*!
 @brief このメソッドは WM_INITDIALOG のメッセージに応答して呼び出されます。
*/
BOOL CInspectUsefulToolsDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// このダイアログのアイコンを設定します。アプリケーションのメイン ウィンドウがダイアログでない場合、
	//  Framework は、この設定を自動的に行います。
	SetIcon(m_hIcon, TRUE);			// 大きいアイコンの設定
	//SetIcon(m_hIcon, FALSE);		// 小さいアイコンの設定

	// メニューの初期化
	InitializeMenuTree();
	InitializeContents();

	// タイトルの設定
	CString strAppName = CString((LPCTSTR)IDS_APP_NAME);
	this->SetWindowText(strAppName);

	CLSID clsid;
	if (CLSIDFromProgID(OLESTR("Excel.Application"), &clsid) == NOERROR){
		// Excel がインストールされている
		LPUNKNOWN lpUnk;
		HRESULT hr;
		LPDISPATCH lpDispatch;
		BOOL bOpenExcel = FALSE;
		if (GetActiveObject(clsid, NULL, &lpUnk) == NOERROR){
			hr = lpUnk->QueryInterface(IID_IDispatch, (LPVOID*)&lpDispatch);
			lpUnk->Release();
			if (hr == NOERROR) {
				//すでにExcelが起動されている状態であればAttachDispatch
				m_inXLApp.AttachDispatch(lpDispatch,TRUE);
				bOpenExcel = TRUE;
			}
		}

		if (m_inXLApp.m_lpDispatch == NULL) {
			bOpenExcel = m_inXLApp.CreateDispatch(clsid);
			m_bOpenXL = TRUE;
		}

		if (bOpenExcel == TRUE) {
			// Excelファイルの初期化
			CWorkbooks inWorkbooks = m_inXLApp.get_Workbooks();
			COleVariant varNull;
			varNull.ChangeType(VT_NULL);

			HRSRC hrSrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDR_MACRO_EXCEL_RCDATA), RT_RCDATA);
			if (hrSrc != NULL) {
				HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hrSrc);

				if (hGlobal != NULL) {
					char *rcData = (char *)LockResource(hGlobal);

					/* リソースサイズの取得 */
					DWORD dwSize = SizeofResource(AfxGetApp()->m_hInstance, hrSrc);

					TCHAR szFilePath[MAX_PATH];
					GetTempPath(MAX_PATH, szFilePath);
					TCHAR szFileName[MAX_PATH];
					GetTempFileName(szFilePath, _T("SubTools_"), 0, szFileName);

					CFile inFile;
					inFile.Open(szFileName, CFile::modeWrite);
					inFile.Write(rcData, dwSize);
					inFile.Close();
					strTempFilePath = szFileName;

					m_inXLBook = inWorkbooks.Open(szFileName
						, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull,varNull, varNull);
					m_bOpenBook = TRUE;
				}
			}
		}
	}

	return TRUE;
}
开发者ID:todesmarz,项目名称:InspectUsefulTools,代码行数:79,代码来源:InspectUsefulToolsDlg.cpp

示例5: Scan


//.........这里部分代码省略.........
		   seq[2]=0;
		else 
		  seq[2]=ptr[MAX_i-1];

		seq[1]=ptr[MAX_i];
		
		if(MAX_i>=Width)
		  seq[0]=0;
		else
		  seq[0]=ptr[MAX_i+1];


		//peak=1/2*(log(seq[0])-log(seq[2]))/(log(seq[0])-2*log(seq[1])+log(seq[2]))+Width-MAX_i;
              peak=(seq[2]-seq[0])/(seq[0]+seq[1]+seq[2])+Width-MAX_i;
           //peak=(2*ptr[MAX_i-2]+ptr[MAX_i-1]-ptr[MAX_i+1]-2*ptr[MAX_i+2])/(ptr[MAX_i+2]+ptr[MAX_i+1]+ptr[MAX_i]+ptr[MAX_i-1]+ptr[MAX_i-2])+Width-MAX_i;
 

        
        /************************计算某行扫描结果*****************************************/

        distance=FS/(PIX_SIZE*peak+ PIX_OFF)+DIST_OFF; 
		if(distance>1800)
		{
           Scan_result[Scan_num][k].X=0;
           Scan_result[Scan_num][k].Y=0;
		   Scan_result[Scan_num][k].Z=0;
		   continue;
		}
		//Theta=atan((k-Height/2)*PIX_SIZE/f);
        Z=(distance-DIST_OFF)*(Height/2-k)*PIX_SIZE/f;
        L1=sqrt(distance*distance+Z*Z);
        

		L3=  distance*tan(PI/2- LaserAngle);
		L2=  sqrt(L1*L1+L3*L3);
		L4=  sqrt(L3*L3+distance*distance);

		r=   sqrt( (L3-rotation_r)*(L3-rotation_r)+distance*distance);

        Phi=Scan_num*Scan_step+PI/2-acos( (rotation_r*rotation_r+r*r-L4*L4)/2.0f/rotation_r/r);


		Scan_result[Scan_num][k].X=r*cos(Phi);
        Scan_result[Scan_num][k].Y=r*sin(Phi);
		Scan_result[Scan_num][k].Z=Z;
		/****************************************************************************/
	
	}
 


	cvReleaseImage(&iplgray);
  /************如果扫描完成,关闭串口,并输出数据********/
	if(Scan_num==Scan_total-1)
	{  
	   MessageBox("扫描完成");
	   Scan_num=0;
	   OnBtnSend('2');
       //OnBtnSend('2');
	   sio_close(Port); //关闭串口
	   /*************数据输出**************/
	   char* fileName=dataout;
	   CString strtemp;

       CFile file;
	   CFileException fileException;
	   if(!file.Open(fileName,CFile::modeCreate | CFile::modeWrite, &fileException))
	   {
		   CString errorInfo;
		   errorInfo.Format("不能打开文件%s,错误:%u\n",fileName,fileException.m_cause);
		   MessageBox(errorInfo,"错误",MB_OK|MB_ICONERROR);
		   return;
	   }

	   for(i=0;i<Scan_total;i++)
		   for(k=0;k<Height;k++)
		   {
			   if(Scan_result[i][k].X==0 & Scan_result[i][k].Y==0 & Scan_result[i][k].Z==0)
                  continue;
			   else
			   { strtemp.Format("%.3f, %.3f, %.3f\r\n\r\n",Scan_result[i][k].X,Scan_result[i][k].Y,Scan_result[i][k].Z);
				   file.Write(strtemp,strtemp.GetLength());
			   }
				  
		   }
	    file.Close();
		MessageBox("已成功输出数据","信息",MB_OK|MB_ICONINFORMATION);  

	   return;
	}
  /**********扫描未完成,发送串口指令***********/
    else
    { 
		OnBtnSend('1');
		//OnBtnSend('1');
		Scan_num=Scan_num+1;
	
    }  
 
}
开发者ID:lzhang57,项目名称:3D_scanner,代码行数:101,代码来源:MainFrm.cpp

示例6: 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

示例7: OnRequestUploadFace

//上传头像
bool CDataBaseSink::OnRequestUploadFace(WORD wRequestID, DWORD dwContextID, VOID * pData, WORD wDataSize)
{
    //数据验证
    ASSERT(wDataSize==sizeof(DBR_GP_UploadCustomFace));
    if (wDataSize!=sizeof(DBR_GP_UploadCustomFace)) return false;

    //数据转换
    DBR_GP_UploadCustomFace *pUploadCustomFace = (DBR_GP_UploadCustomFace*)pData;

    //文件定义
    CFile fileCustomFace;
    TCHAR szFileName[128];
    _snprintf(szFileName, CountArray(szFileName), TEXT("%s\\UploadFile_%ld.zip"), theApp.m_szDirWork, pUploadCustomFace->dwUserID);

    try
    {
        if ( fileCustomFace.Open( szFileName, CFile::modeRead|CFile::typeBinary) )
        {
            BYTE cbCustomFaceData[1024*30];

            //读取文件
            UINT uReadSize = fileCustomFace.Read(cbCustomFaceData, CountArray(cbCustomFaceData));

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

            LONG lRet=-1;
            try
            {
                lRet = SPUploadFace(pUploadCustomFace->dwUserID, cbCustomFaceData, uReadSize);
            }
            catch (IDataBaseException * pIException)
            {
                //错误信息
                LPCTSTR pszDescribe=pIException->GetExceptionDescribe();
                CTraceService::TraceString(pszDescribe,TraceLevel_Exception);
            }

            //成功判断
            if ( lRet != -1 )
            {
                DBR_GP_UploadFaceResult UploadFaceResult;
                ZeroMemory(&UploadFaceResult, sizeof(UploadFaceResult));
                lstrcpyn(UploadFaceResult.szDescribeMsg, TEXT("头像上传成功!"), sizeof(UploadFaceResult.szDescribeMsg));
                UploadFaceResult.dwFaceVer=lRet;
                UploadFaceResult.bOperateSuccess=true;

                m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBR_GP_UPLOAD_FACE_RESULT,dwContextID,
                        &UploadFaceResult,sizeof(UploadFaceResult));
            }
            else
            {
                //操作失败
                DBR_GP_UploadFaceResult UploadFaceResult;
                ZeroMemory(&UploadFaceResult, sizeof(UploadFaceResult));
                lstrcpyn(UploadFaceResult.szDescribeMsg, TEXT("由于数据库操作异常,请重新上传!"), sizeof(UploadFaceResult.szDescribeMsg));
                UploadFaceResult.bOperateSuccess=false;

                m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBR_GP_UPLOAD_FACE_RESULT,dwContextID,
                        &UploadFaceResult,sizeof(UploadFaceResult));
            }

            //删除文件
            CFile::Remove(szFileName);
        }
    } catch(...) {}

    return true;
}
开发者ID:liangzai90,项目名称:WH2008,代码行数:70,代码来源:DataBaseSink.cpp

示例8: Load

bool CPlayListPLS::Load(const std::string &strFile)
{
  //read it from the file
  std::string strFileName(strFile);
  m_strPlayListName = URIUtils::GetFileName(strFileName);

  Clear();

  bool bShoutCast = false;
  if( StringUtils::StartsWithNoCase(strFileName, "shout://") )
  {
    strFileName.replace(0, 8, "http://");
    m_strBasePath = "";
    bShoutCast = true;
  }
  else
    URIUtils::GetParentPath(strFileName, m_strBasePath);

  CFile file;
  if (!file.Open(strFileName) )
  {
    file.Close();
    return false;
  }

  if (file.GetLength() > 1024*1024)
  {
    CLog::Log(LOGWARNING, "%s - File is larger than 1 MB, most likely not a playlist",__FUNCTION__);
    return false;
  }

  char szLine[4096];
  std::string strLine;

  // run through looking for the [playlist] marker.
  // if we find another http stream, then load it.
  while (1)
  {
    if ( !file.ReadString(szLine, sizeof(szLine) ) )
    {
      file.Close();
      return size() > 0;
    }
    strLine = szLine;
    StringUtils::Trim(strLine);
    if(StringUtils::EqualsNoCase(strLine, START_PLAYLIST_MARKER))
      break;

    // if there is something else before playlist marker, this isn't a pls file
    if(!strLine.empty())
      return false;
  }

  bool bFailed = false;
  while (file.ReadString(szLine, sizeof(szLine) ) )
  {
    strLine = szLine;
    StringUtils::RemoveCRLF(strLine);
    size_t iPosEqual = strLine.find("=");
    if (iPosEqual != std::string::npos)
    {
      std::string strLeft = strLine.substr(0, iPosEqual);
      iPosEqual++;
      std::string strValue = strLine.substr(iPosEqual);
      StringUtils::ToLower(strLeft);
      StringUtils::TrimLeft(strLeft);

      if (strLeft == "numberofentries")
      {
        m_vecItems.reserve(atoi(strValue.c_str()));
      }
      else if (StringUtils::StartsWith(strLeft, "file"))
      {
        vector <int>::size_type idx = atoi(strLeft.c_str() + 4);
        if (!Resize(idx))
        {
          bFailed = true;
          break;
        }

        // Skip self - do not load playlist recursively
        if (StringUtils::EqualsNoCase(URIUtils::GetFileName(strValue),
                                      URIUtils::GetFileName(strFileName)))
          continue;

        if (m_vecItems[idx - 1]->GetLabel().empty())
          m_vecItems[idx - 1]->SetLabel(URIUtils::GetFileName(strValue));
        CFileItem item(strValue, false);
        if (bShoutCast && !item.IsAudio())
          strValue.replace(0, 7, "shout://");

        strValue = URIUtils::SubstitutePath(strValue);
        CUtil::GetQualifiedFilename(m_strBasePath, strValue);
        g_charsetConverter.unknownToUTF8(strValue);
        m_vecItems[idx - 1]->SetPath(strValue);
      }
      else if (StringUtils::StartsWith(strLeft, "title"))
      {
        vector <int>::size_type idx = atoi(strLeft.c_str() + 5);
        if (!Resize(idx))
//.........这里部分代码省略.........
开发者ID:7orlum,项目名称:xbmc,代码行数:101,代码来源:PlayListPLS.cpp

示例9: brush

// 转换RGB
void CRGB2YUVView::OnConvertPAL() 
{
	CDC *pDC = GetDC();
	CRect rect;
	CBrush brush(RGB(128,128,128));
	GetClientRect(&rect);
	pDC->FillRect(&rect, &brush);

	// PAL 720x576 : 中国的电视标准为PAL制	
	int CurrentXRes = 720;
	int CurrentYRes = 576;
	int size        = CurrentXRes * CurrentYRes;
    
	// 分配内存
	byte *Video_Field0 = (byte*)malloc(CurrentXRes*CurrentYRes);  
	byte *Video_Field1 = (byte*)malloc(CurrentXRes*CurrentYRes);
	
	// 保存内存指针
	byte *Video_Field0_ = Video_Field0;
	byte *Video_Field1_ = Video_Field1;

	byte yuv_y0, yuv_u0, yuv_v0, yuv_v1;  // {y0, u0, v0, v1};
	byte bufRGB[3];  // 临时保存{R,G,B}
	byte bufYUV[3];  // 临时保存{Y,U,V}

	// 初始化数组空间
    ZeroMemory(bufRGB, sizeof(byte)*3);
	ZeroMemory(bufYUV, sizeof(byte)*3);

	// 初始化内存
	ZeroMemory(Video_Field0, CurrentXRes*CurrentYRes);
	ZeroMemory(Video_Field1, CurrentXRes*CurrentYRes);
	
	// BMP 位图操作
	BITMAPFILEHEADER bmfh;
	BITMAPINFOHEADER bmih;

    char strFileName[MAX_PATH]="720bmp.bmp";
	CFile* f;
	f = new CFile();
	f->Open(strFileName, CFile::modeRead);
	f->SeekToBegin();
	f->Read(&bmfh, sizeof(bmfh));
	f->Read(&bmih, sizeof(bmih));
 
    // 分配图片像素内存
    RGBTRIPLE *rgb;
	rgb = new RGBTRIPLE[bmih.biWidth*bmih.biHeight];

	f->SeekToBegin();
	f->Seek(54,CFile::begin);  // BMP 54个字节之后的是位像素数据
	f->Read(rgb, bmih.biWidth * bmih.biHeight * 3);	 // 这里只读24位RGB(r,g,b)图像
	
	// 上场  (1,3,5,7...行)
	for (int i = bmih.biHeight-1; i>=0; i--) {
		for (int j = 0; j<bmih.biWidth; j++) {
			if(!(i%2)==0) 
			{
				bufRGB[0] = rgb[i*bmih.biWidth+j].rgbtRed;   //	R
				bufRGB[1] = rgb[i*bmih.biWidth+j].rgbtGreen; // G
				bufRGB[2] = rgb[i*bmih.biWidth+j].rgbtBlue;  // B

				// RGB转换为YUV
				RGB2YUV(bufRGB,bufYUV);
				yuv_y0 = bufYUV[0];   // y
				yuv_u0 = bufYUV[1];   // u
				yuv_v0 = bufYUV[2];   // v
				
				for (int k=0; k<1000; k++) ;  //延时
				// 视图中显示
				pDC->SetPixel(j, (bmih.biHeight-1)-i, RGB(bufRGB[0], bufRGB[1], bufRGB[2]));
				
				// UYVY标准  [U0 Y0 V0 Y1] [U1 Y2 V1 Y3] [U2 Y4 V2 Y5] 每像素点两个字节,[内]为四个字节 
				if ((j%2)==0) 
				{
					*Video_Field0 = yuv_u0;  
					Video_Field0++;
					yuv_v1 = yuv_v0;   // v保存起来供下一字节使用
				} 
				else
				{
					*Video_Field0 = yuv_v1;  
					Video_Field0++;
				}
				*Video_Field0 = yuv_y0;      
				Video_Field0++;
			}// end if i%2
		}
	}

    // 下场 (2,4,6,8...行)
	for (int i_ = bmih.biHeight-1; i_>=0; i_--) {
		for (int j_ = 0; j_<bmih.biWidth; j_++) {
			if((i_%2)==0) 
			{
				bufRGB[0] = rgb[i_*bmih.biWidth+j_].rgbtRed;   //	R
				bufRGB[1] = rgb[i_*bmih.biWidth+j_].rgbtGreen; // G
				bufRGB[2] = rgb[i_*bmih.biWidth+j_].rgbtBlue;  // B

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

示例10: 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

示例11: 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

示例12: 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

示例13: TokGen

///////////////////////////////////////////////////////////////////////////////
// This function will parse the source file and create the token file
CMainApp::Error_Codes CMainApp::TokGen()
{
    Error_Codes ReturnErr = ERR_NOERROR;    
    
    WriteCon(CONERR, "%s\r\n", CalcTab("", 79, '-'));

    // Open the iodll.dll using the first file name
    HANDLE hModule = RSOpenModule(m_strInExe, NULL);
    if ((int)hModule < 100) {
            // error or warning
            WriteCon(CONERR, "%s", CalcTab(m_strInExe, m_strInExe.GetLength()+5, ' '));
            IoDllError((int)hModule);
            return ERR_FILE_NOTSUPP;
    } else {
        // before we do anything else we have to check how many languages we have in the file
        CString strLang;
        char szLang[8];
        BOOL b_multi_lang = FALSE;
        USHORT usInputLang = MAKELANGID(m_usIPriLangId, m_usISubLangId);

        if((b_multi_lang = RSLanguages(hModule, strLang.GetBuffer(128))) && !IsFlag(INPUT_LANG))
        {
            // this is a multiple language file but we don't have an input language specified
            // Fail, but warn the user that he has to set the input language to continue.
            strLang.ReleaseBuffer();
            WriteCon(CONERR, "Multiple language file. Please specify an input language %s.\r\n", strLang);
            goto exit; 
        }

        // Convert the language in to the hex value
        sprintf(szLang,"0x%3.3X", usInputLang);

        // Check if the input language that we got is a valid one
        if(IsFlag(INPUT_LANG) && strLang.Find(szLang)==-1)
        {
            WriteCon(CONERR, "The language %s in not a valid language for this file.\r\n", szLang);
            WriteCon(CONERR, "Valid languages are: %s.\r\n", strLang);
            goto exit;
        }

        // Check if the user is extracting the neutral language
        if(!usInputLang)
            usInputLang = 0xFFFF;

        // Open the output file 
        CStdioFile fileOut;
        if(!fileOut.Open(m_strTgtTok, CFile::modeCreate | CFile::modeReadWrite)) {
            WriteCon(CONERR, "Cannot create file: %s\r\n", CalcTab(m_strTgtTok, m_strTgtTok.GetLength()+5, ' '));
            return ERR_FILE_CREATE;
        }

        CString strBmpDir = "";
        CString strFileName = m_strInExe;
        int pos = m_strInExe.ReverseFind('\\');
        if(pos!=-1)
        {
            strFileName = m_strInExe.Right(m_strInExe.GetLength()-pos-1);
        }
        else 
        if((pos = m_strInExe.ReverseFind(':'))!=-1)
        {
            strFileName = m_strInExe.Right(m_strInExe.GetLength()-pos-1);
        }
        
        pos = m_strTgtTok.ReverseFind('\\');
        if(pos!=-1)
        {
            strBmpDir = m_strTgtTok.Left(pos+1);
        }
        else 
        if((pos = m_strTgtTok.ReverseFind(':'))!=-1)
        {
            strBmpDir = m_strTgtTok.Left(pos+1);
        }

        // inform the user ...
        WriteCon(CONOUT, "Processing\t");
        WriteCon(CONBOTH, "%s", CalcTab(strFileName, strFileName.GetLength()+5, ' '));
        
		LPCSTR lpszType = 0L;
        LPCSTR lpszRes = 0L;
        DWORD  dwLang = 0L;
        DWORD  dwItem = 0L;
        DWORD  dwItemID = 0L;
        LPRESITEM lpResItem = NULL;

        CString strToken;
        CString strResName;
        CString strCaption;
        WORD wFlag;
        BOOL bSkip = FALSE;
        BOOL bSkipEmpty = FALSE;
        BOOL bSkipLang = FALSE;
        WORD wCount = 0;

        WORD wMsgCount = 0;
        int iPos = 1;
        int iBmpIdCount = 0;
//.........这里部分代码省略.........
开发者ID:mingpen,项目名称:OpenNT,代码行数:101,代码来源:tokgen.cpp

示例14: Read

int CModel::Read (char *filename, short nModel, int bFlipV, int bCustom)
{
if (m_nModel >= 0)
	return 0;

	CFile			cf;
	char			fileId [4];
	int			i, nLength, nFrames, nSubModels, bTimed = 0;

bLogOOF = (fErr != NULL) && FindArg ("-printoof");
nIndent = 0;
OOF_PrintLog ("\nreading %s/%s\n", gameFolders.szModelDir [bCustom], filename);
if (!(*filename && cf.Open (filename, gameFolders.szModelDir [bCustom], "rb", 0))) {
	OOF_PrintLog ("  file not found");
	return 0;
	}

if (!cf.Read (fileId, sizeof (fileId), 1)) {
	OOF_PrintLog ("  invalid file id\n");
	cf.Close ();
	return 0;
	}
if (strncmp (fileId, "PSPO", 4)) {
	OOF_PrintLog ("  invalid file id\n");
	cf.Close ();
	return 0;
	}
Init ();

m_nModel = nModel;
m_bCustom = bCustom;

m_nVersion = OOF_ReadInt (cf, "nVersion");
if (m_nVersion >= 2100)
	m_nFlags |= OOF_PMF_LIGHTMAP_RES;
if (m_nVersion >= 22) {
	bTimed = 1;
	m_nFlags |= OOF_PMF_TIMED;
	m_frameInfo.m_nFirstFrame = 0;
	m_frameInfo.m_nLastFrame = 0;
	}
nSubModels = 0;

while (!cf.EoF ()) {
	char chunkID [4];

	if (!cf.Read (chunkID, sizeof (chunkID), 1)) {
		cf.Close ();
		return 0;
		}
	OOF_PrintLog ("  chunkID = '%c%c%c%c'\n", chunkID [0], chunkID [1], chunkID [2], chunkID [3]);
	nLength = OOF_ReadInt (cf, "nLength");
	switch (ListType (chunkID)) {
		case 0:
			if (!ReadTextures (cf)) {
				Destroy ();
				return 0;
				}
			break;

		case 1:
			if (!ReadInfo (cf)) {
				Destroy ();
				return 0;
				}
			break;

		case 2:
			if (!m_subModels [nSubModels].Read (cf, this, bFlipV)) {
				Destroy ();
				return 0;
				}
			nSubModels++;
			break;

		case 3:
			if (!m_gunPoints.Read (cf, m_nVersion >= 1908, MAX_GUNS)) {
				Destroy ();
				return 0;
				}
			break;

		case 4:
			if (!m_specialPoints.Read (cf)) {
				Destroy ();
				return 0;
				}
			break;

		case 5:
			if (!m_attachPoints.Read (cf)) {
				Destroy ();
				return 0;
				}
			break;

		case 6:
			nFrames = m_frameInfo.m_nFrames;
			if (!bTimed)
				m_frameInfo.m_nFrames = OOF_ReadInt (cf, "nFrames");
//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,代码来源:oofread.cpp

示例15: GenLineInitTXT


//.........这里部分代码省略.........
		return;
	}
	if (uiMax < (m_uiLAUXNum + m_uiBlastMachineNum + m_uiLAUXNum))
	{
		uiMax = m_uiLAUXNum + m_uiBlastMachineNum + m_uiLAUXNum;
	}
	uiLAULNum = (uiMax / 2) / (m_uiIntervalLAUL + 1) + (uiMax - uiMax / 2) / (m_uiIntervalLAUL + 1);
	unsigned int uiLineCount = (uiLineNum + 1) * 2 - 1;
	unsigned int uiColumnCount = (m_uiLAUXNum + uiLAULNum + uiMax) * 2 - 1 + 2;
	uiCharSize = uiLineCount * uiColumnCount;
	unsigned char * pWriteChar = new unsigned char [uiCharSize];
	unsigned char ucInit = ' ';
	memset(pWriteChar, ucInit, uiCharSize);
	// 回车换行赋值
	for (unsigned int i=0; i<uiLineCount; i++)
	{
		uiPosition = (i + 1) * uiColumnCount - 2;
		pWriteChar[uiPosition] = '\r';
		uiPosition = (i + 1) * uiColumnCount - 1;
		pWriteChar[uiPosition] = '\n';
	}
	// 交叉站及交叉线赋值
	for (unsigned int i=0; i<uiLineCount; i++)
	{
		uiPosition = (uiMax - uiMax / 2 + (uiMax - uiMax / 2) / (m_uiIntervalLAUL + 1)) * 2 + i * uiColumnCount;
		if (i == 0)
		{
			pWriteChar[uiPosition] = LAUX_LOGO;
		}
		else if (i % 2 == 1)
		{
			pWriteChar[uiPosition] = LAUXLINE_LOGO;
		}
		else
		{
			pWriteChar[uiPosition] = LAU_LOGO;
		}
	}
	// 左侧爆炸机赋值
	uiPosition = (uiMax - uiMax / 2 + (uiMax - uiMax / 2) / (m_uiIntervalLAUL + 1)) * 2;
	for (unsigned int i=0; i<m_uiBlastMachineNum; i++)
	{
		pWriteChar[uiPosition - i * 2 - 1] = LINE_LOGO;
		pWriteChar[uiPosition - i * 2 - 2] = BLAST_LOGO;
	}
	// 右侧辅助道赋值
	uiPosition = (uiMax - uiMax / 2 + (uiMax - uiMax / 2) / (m_uiIntervalLAUL + 1)) * 2;
	for (unsigned int i=0; i<m_uiAuxNum; i++)
	{
		pWriteChar[uiPosition + i * 2 + 1] = LINE_LOGO;
		pWriteChar[uiPosition + i * 2 + 2] = AUX_LOGO;
	}
	unsigned int uiFDUNumLeft = 0;		// 左侧采集站个数
	unsigned int uiFDUNumRight = 0;		// 右侧采集站个数
	// 采集站及电源站赋值
	for (unsigned int i=2; i<uiLineCount; i++)
	{
		if (i % 2 == 0)
		{
			uiPosition = (uiMax - uiMax / 2 + (uiMax - uiMax / 2) / (m_uiIntervalLAUL + 1)) * 2 + i * uiColumnCount;
			uiFDUNumRight = m_vecLine[(i - 2) / 2] / 2;
			uiFDUNumLeft = m_vecLine[(i - 2) / 2] - uiFDUNumRight;
			// 左侧采集站及电源站赋值
			for (unsigned int j=0; j<(uiFDUNumLeft + uiFDUNumLeft / (m_uiIntervalLAUL + 1)); j++)
			{
				pWriteChar[uiPosition - j * 2 - 1] = LINE_LOGO;
				if (((j + 1) % (m_uiIntervalLAUL + 1) == 0) && (j != 0))
				{
					pWriteChar[uiPosition - j * 2 - 2] = LAUL_LOGO;
				}
				else
				{
					pWriteChar[uiPosition - j * 2 - 2] = FDU_LOGO;
				}
			}
			// 右侧采集站及电源站赋值
			for (unsigned int j=0; j<(uiFDUNumRight + uiFDUNumRight / (m_uiIntervalLAUL + 1)); j++)
			{
				pWriteChar[uiPosition + j * 2 + 1] = LINE_LOGO;
				if (((j + 1) % (m_uiIntervalLAUL + 1) == 0) && (j != 0))
				{
					pWriteChar[uiPosition + j * 2 + 2] = LAUL_LOGO;
				}
				else
				{
					pWriteChar[uiPosition + j * 2 + 2] = FDU_LOGO;
				}
			}
		}	
	}
	if (FALSE == file.Open(strPath, CFile::modeCreate|CFile::modeWrite))
	{
		AfxMessageBox(_T("Create LineInit file error, Please check it again!"));
		return;
	}
	// 写文件内容
	file.Write(pWriteChar, uiCharSize);
	file.Close();
	delete[] pWriteChar;
}
开发者ID:liquanhai,项目名称:cxm-hitech-matrix428,代码行数:101,代码来源:FraseSPSToXML.cpp


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