本文整理汇总了C++中CFile类的典型用法代码示例。如果您正苦于以下问题:C++ CFile类的具体用法?C++ CFile怎么用?C++ CFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dogetlong
DWORD dogetlong(CFile f)
{
DWORD x;
f.Read(&x, sizeof(x));
return x;
}
示例2: CreateDirectory
void CBuildMap::OnButtonBuild()
{
CreateDirectory(m_pDoc->m_RunPath + "Graphing\\", NULL);
CFile MapFile;
if(!MapFile.Open(m_pDoc->m_RunPath + "Graphing\\graph.txt", CFile::modeCreate | CFile::modeWrite))
return;
CString strHops, strHeight, strWidth;
// Get hops pref
m_ebHops.GetWindowText(strHops);
int MaxHops = 3;
if(strHops != "")
MaxHops = atoi(strHops);
// Get height pref
m_ebHeight.GetWindowText(strHeight);
int MapHeight = 3;
if(strHeight != "")
MapHeight = atoi(strHeight);
// Get width pref
m_ebWidth.GetWindowText(strWidth);
int MapWidth = 3;
if(strWidth != "")
MapWidth = atoi(strWidth);
// Graph header, default settings here
CString Header = "graph GnutellaNet \r\n";
Header += "{ \r\n";
Header += "\t size=\"" + DWrdtoStr(MapHeight) + "," + DWrdtoStr(MapWidth) + "\" \r\n";
Header += "\t graph[center=\"" + InsertDecimal((double)MapHeight / 2) + "," + InsertDecimal((double)MapWidth / 2) + "\"] \r\n";
Header += "\t node [shape=circle,width=.2,height=.2,label=\"\"] \r\n";
// Put ourselves at the center of the graph
/*CString DotSize = GetDotSize(m_pDoc->m_pShare->m_TotalLocalFiles);
CString Size = "width=." + DotSize;
Size += ", height=." + DotSize;
Header += "\r\n\t 0 [label=\"You\", fontsize=10, style=filled, color=red, " + Size + "] \r\n\r\n";
MapFile.Write(Header, Header.GetLength());*/
m_DetailList.clear();
//// Map all the branches of nodes from us
//for(int i = 0; i < m_pComm->m_NodeList.size(); i++)
//{
// CGnuNode* p = m_pComm->m_NodeList[i];
// if(m_pComm->m_NodeList[i]->m_Status != SOCK_CONNECTED)
// continue;
// // Maps the node directly connected
// for(int j = 0; j < p->LocalMap[0].size(); j++)
// {
// CString NextNode = "\t " + DWrdtoStr(0) + " -- ";
// NextNode += DWrdtoStr(p->LocalMap[0][j]) + " [" + GetMapColor(1) + "]\r\n";
// MapFile.Write(NextNode, NextNode.GetLength());
// }
// // Maps node connections
// for(j = 0; j < p->MapLinkList.size(); j++)
// {
// bool Insert = false;
// if(p->MapLinkList[j].Hops <= MaxHops)
// Insert = true;
// if(Insert)
// {
// AddDetail(p->MapLinkList[j].ParentID);
// AddDetail(p->MapLinkList[j].ID);
// CString NodeLink = "\t " + DWrdtoStr( p->MapLinkList[j].ParentID );
// NodeLink += " -- ";
// NodeLink += DWrdtoStr(p->MapLinkList[j].ID) + " [" + GetMapColor(p->MapLinkList[j].Hops) + "]\r\n";
//
// MapFile.Write(NodeLink, NodeLink.GetLength());
// }
// }
// MapFile.Write("\r\n\r\n", 4);
//}
// Write each node's details
//m_DetailList.sort();
//
//std::list<DWORD>::iterator itNode;
//for(itNode = m_DetailList.begin(); itNode != m_DetailList.end(); itNode++)
// for(i = 0; i < m_pComm->MapTable.size(); i++)
// if(*itNode == m_pComm->MapTable[i].MapID)
// {
// // Get size of node
// CString Size;
// if(m_chkSizeNodes.GetCheck())
// {
// DotSize = GetDotSize(m_pComm->MapTable[i].FileSize);
//.........这里部分代码省略.........
示例3: ReadEffectClip
void ReadEffectClip (tEffectClip& ec, CFile& cf)
{
ReadVideoClip (ec.vClipInfo, cf);
ec.xTimeLeft = cf.ReadFix ();
ec.nCurFrame = cf.ReadInt ();
ec.changingWallTexture = cf.ReadShort ();
ec.changingObjectTexture = cf.ReadShort ();
ec.flags = cf.ReadInt ();
ec.nCritClip = cf.ReadInt ();
ec.nDestBm = cf.ReadInt ();
ec.nDestVClip = cf.ReadInt ();
ec.nDestEClip = cf.ReadInt ();
ec.xDestSize = cf.ReadFix ();
ec.nSound = cf.ReadInt ();
ec.nSegment = cf.ReadInt ();
ec.nSide = cf.ReadInt ();
}
示例4: ReadTimeStamp
static inline void ReadTimeStamp(CFile& file, CTime& timeStamp)
{
unsigned __int64 time;
file.Read(&time, sizeof(unsigned __int64));
timeStamp = (time_t)time;
}
示例5: ASSERT
//上传头像
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_s(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;
}
示例6: while
void CRssReader::Process()
{
while (GetQueueSize())
{
CSingleLock lock(m_critical);
int iFeed = m_vecQueue.front();
m_vecQueue.erase(m_vecQueue.begin());
m_strFeed[iFeed].clear();
m_strColors[iFeed].clear();
CCurlFile http;
http.SetUserAgent(g_advancedSettings.m_userAgent);
http.SetTimeout(2);
std::string strXML;
std::string strUrl = m_vecUrls[iFeed];
lock.Leave();
int nRetries = 3;
CURL url(strUrl);
std::string fileCharset;
// we wait for the network to come up
if ((url.IsProtocol("http") || url.IsProtocol("https")) &&
!CServiceBroker::GetNetwork().IsAvailable())
{
CLog::Log(LOGWARNING, "RSS: No network connection");
strXML = "<rss><item><title>"+g_localizeStrings.Get(15301)+"</title></item></rss>";
}
else
{
XbmcThreads::EndTime timeout(15000);
while (!m_bStop && nRetries > 0)
{
if (timeout.IsTimePast())
{
CLog::Log(LOGERROR, "Timeout while retrieving rss feed: %s", strUrl.c_str());
break;
}
nRetries--;
if (!url.IsProtocol("http") && !url.IsProtocol("https"))
{
CFile file;
auto_buffer buffer;
if (file.LoadFile(strUrl, buffer) > 0)
{
strXML.assign(buffer.get(), buffer.length());
break;
}
}
else
{
if (http.Get(strUrl, strXML))
{
fileCharset = http.GetProperty(XFILE::FILE_PROPERTY_CONTENT_CHARSET);
CLog::Log(LOGDEBUG, "Got rss feed: %s", strUrl.c_str());
break;
}
else if (nRetries > 0)
Sleep(5000); // Network problems? Retry, but not immediately.
else
CLog::Log(LOGERROR, "Unable to obtain rss feed: %s", strUrl.c_str());
}
}
http.Cancel();
}
if (!strXML.empty() && m_pObserver)
{
// erase any <content:encoded> tags (also unsupported by tinyxml)
size_t iStart = strXML.find("<content:encoded>");
size_t iEnd = 0;
while (iStart != std::string::npos)
{
// get <content:encoded> end position
iEnd = strXML.find("</content:encoded>", iStart) + 18;
// erase the section
strXML = strXML.erase(iStart, iEnd - iStart);
iStart = strXML.find("<content:encoded>");
}
if (Parse(strXML, iFeed, fileCharset))
CLog::Log(LOGDEBUG, "Parsed rss feed: %s", strUrl.c_str());
}
}
UpdateObserver();
}
示例7: doputshort
void doputshort(unsigned short int x, CFile f)
{
f.Write(&x, sizeof(x));
}
示例8: stream
short int CDBConverter::LoadHDR(CFile fp, bool DXMode)// send to the function the FILE pointer of your open file stream (Koreaobj.hdr)
{
int c,d;
int cc;
// Zero out HDR records
ZeroMemory(&hdrLOD,sizeof(hdrLOD));
ZeroMemory(&hdrLODRes,sizeof(hdrLODRes));
cc = 0;
hdr.version = dogetlong(fp);// dogetlong simply reads in a 4 byte integer
// since the Mac reads bytes differently, I use a function to read in the bytes and reverse the order.
hdr.nColor = dogetlong(fp);
if((hdr.nColor > MAX_COLOR) | (hdr.nColor < 1))
return (1);
hdr.nDarkColor = dogetlong(fp);
for(c=0;c<hdr.nColor;c++)
{
for(d=0;d<4;d++)
hdrColor[c].f[d] = dogetfloat(fp);// dogetfloat reads in a 4 byte float
if (c == 774) // Formation strip-lights
{
hdrColor[c].f[0] = 0.6f;
hdrColor[c].f[1] = 0.6f;
hdrColor[c].f[2] = 0.0f;
}
}
hdr.nPalette = dogetlong(fp);
if((hdr.nPalette > MAX_PALETTE) | (hdr.nPalette < 1))
// return (2);
cc = 2;
for(c=0;c<hdr.nPalette;c++)
{
for(d=0;d<256;d++)
{
hdrPalette[c].r[d] = dogetchar(fp);
hdrPalette[c].g[d] = dogetchar(fp);
hdrPalette[c].b[d] = dogetchar(fp);
hdrPalette[c].a[d] = dogetchar(fp);
}
hdrPalette[c].uint[0] = dogetlong(fp);
hdrPalette[c].uint[1] = dogetlong(fp);
}
hdr.nTexture = dogetlong(fp);
if((hdr.nTexture > MAX_TEXTURE) | (hdr.nTexture < 1))
return (3);
hdr.unk[0] = dogetlong(fp); // Largest texture (compressed size)
for(c=0;c<hdr.nTexture;c++)
{
for(d=0;d<10;d++)
hdrTexture[c].uint[d] = dogetlong(fp);
}
hdr.unk[1] = dogetlong(fp); // Max number of nodes
maxNodes = hdr.unk[1];
if (hdr.unk[1] < MAX_NODES)
maxNodes = hdr.unk[1] = MAX_NODES;
hdr.nLOD = dogetlong(fp);
LastLOD = hdr.nLOD;
if((hdr.nLOD > MAX_LOD) | (hdr.nLOD < 1))
return (4);
for(c=0;c<hdr.nLOD;c++)
{
for(d=0;d<5;d++) // [0], [1], [2] not used
hdrLOD[c].uint[d] = dogetlong(fp); // [3] KO.lod file offset
// [4] LOD length
}
hdr.nParent = dogetlong(fp);
if((hdr.nParent > MAX_PARENT) | (hdr.nParent < 1))
return (5);
for(c=0;c<hdr.nParent;c++)
{
for(d=0;d<7;d++)
hdrParent[c].f[d] = dogetfloat(fp); // Hitbox +"radius" (shadow size???)
for(d=0;d<2;d++)
hdrParent[c].uint[d] = dogetlong(fp); // file offset [0] & size [1]
for(d=0;d<2;d++)
hdrParent[c].ushort1[d] = dogetshort(fp);// nTexures [0] & nDynamics[1]
for(d=0;d<4;d++)
hdrParent[c].uchar[d] = dogetchar(fp); // nLODs [0], nSwitches [1], nDOFs [2], nSlots [3]
for(d=0;d<2;d++)
hdrParent[c].ushort2[d] = dogetshort(fp); // Unk1 [0] & Unk2 [1]
}
for(c=0;c<hdr.nParent;c++)
{
if(hdrParent[c].uchar[3] > 100)
return (6);
if(hdrParent[c].uchar[3] > 0)// Load Slots
{
for(d=0;d<hdrParent[c].uchar[3];d++)
{
hdrLODRes[c].slot1[d] = dogetfloat(fp);
hdrLODRes[c].slot2[d] = dogetfloat(fp);
hdrLODRes[c].slot3[d] = dogetfloat(fp);
}
}
if(hdrParent[c].ushort1[1] > 10)
return (7);
if(hdrParent[c].ushort1[1] > 0)// Load Dynamic
//.........这里部分代码省略.........
示例9: doputfloat
void doputfloat(float x, CFile f)
{
f.Write(&x, sizeof(x));
}
示例10: doputchar
void doputchar(char x, CFile f)
{
f.Write(&x, sizeof(x));
}
示例11: doputlong
void doputlong(long x, CFile f)
{
f.Write(&x, sizeof(x));
}
示例12: dogetshort
unsigned short int dogetshort(CFile f)
{
unsigned short int x;
f.Read(&x, sizeof(x));
return x;
}
示例13: dogetchar
char dogetchar(CFile f)
{
char x;
f.Read(&x, sizeof(x));
return x;
}
示例14: SaveVMS
// ============================================================================
bool CVisualMSDoc::SaveVMS(const CString &fname, bool bSelOnly)
{
CFile f;
if(!f.Open(fname, CFile::modeCreate | CFile::modeWrite))
{
MessageBoxf(MaxSDK::GetResourceStringAsMSTR(IDS_ERROR_SAVING_FILE_), (LPCTSTR)fname);
return false;
}
CArchive ar(&f, CArchive::store);
VmsHeader hdr;
hdr.magic = VMS_MAGIC;
hdr.version = VMS_VERSION;
CUIntArray selArr;
if(bSelOnly)
{
GetSelectionSet(selArr);
hdr.numObj = GetSelectionCount();
}
else
hdr.numObj = m_objects.GetSize();
// store the whole header with one write
ar.Write(&hdr, sizeof(VmsHeader));
for(int i = 0; i < hdr.numObj; i++)
{
CGuiObj *obj;
if(bSelOnly)
obj = (CGuiObj*)m_objects[selArr[i]];
else
obj = (CGuiObj*)m_objects[i];
ar << obj->m_createID;
int numProps = obj->m_properties.GetSize();
ar << numProps;
for(int j = 0; j < numProps; j++)
{
CProperty *prop = &obj->m_properties[j];
ar << prop->m_name;
ar << prop->m_type;
ar << prop->m_flags;
switch(prop->m_type)
{
case PROP_INTEGER:
case PROP_OPTION:
ar << prop->m_integer;
break;
case PROP_BOOLEAN:
ar << (BOOL)prop->m_boolean;
break;
case PROP_REAL:
ar << prop->m_real;
break;
case PROP_ARRAY:
SaveStringArray(ar, prop->m_array);
break;
case PROP_STRING:
case PROP_FILENAME:
ar << prop->m_string;
break;
// if the property type is not supported by the VMS file I/O
// write it as a string
default:
{
CString str = (LPCTSTR)*prop;
ar << str;
}
break;
}
}
int numEvents = obj->m_handlers.GetSize();
ar << numEvents;
for(int j = 0; j < numEvents; j++)
{
CHandler *hndlr = &obj->m_handlers[j];
ar << (BOOL)hndlr->m_use;
ar << hndlr->m_name;
ar << hndlr->m_args;
ar << hndlr->m_text;
}
}
// close the archive and file handle
ar.Close();
f.Close();
return true;
}
示例15: SaveHDR
void CDBConverter::SaveHDR(CFile fp, bool DXMode)
{
int c,d;
char LODName[HDR_LODNAMELEN];
doputlong((long)hdr.version,fp);
if(hdr.nColor > MAX_COLOR)
hdr.nColor = MAX_COLOR;
doputlong((long)hdr.nColor,fp);
doputlong((long)hdr.nDarkColor,fp);
for(c=0;c<hdr.nColor;c++)
{
for(d=0;d<4;d++)
doputfloat(hdrColor[c].f[d],fp);
}
if(hdr.nPalette > MAX_PALETTE)
hdr.nPalette = MAX_PALETTE;
doputlong(hdr.nPalette,fp);
for(c=0;c<hdr.nPalette;c++)
{
for(d=0;d<256;d++)
{
doputchar(hdrPalette[c].r[d],fp);
doputchar(hdrPalette[c].g[d],fp);
doputchar(hdrPalette[c].b[d],fp);
doputchar(hdrPalette[c].a[d],fp);
}
doputlong(hdrPalette[c].uint[0],fp);
doputlong(hdrPalette[c].uint[1],fp);
}
if(hdr.nTexture > MAX_TEXTURE)
hdr.nTexture = MAX_TEXTURE;
doputlong(hdr.nTexture,fp);// 21
doputlong(hdr.unk[0],fp);
for(c=0;c<hdr.nTexture;c++)
{
for(d=0;d<10;d++)
doputlong(hdrTexture[c].uint[d],fp);
}
// Make sure max number of nodes is big enough
if (hdr.unk[1] < 10000)
hdr.unk[1] = 10000;
doputlong(hdr.unk[1],fp);
if(hdr.nLOD > MAX_LOD)
hdr.nLOD = MAX_LOD;
doputlong(hdr.nLOD,fp);// 54
for(c=0;c<hdr.nLOD;c++)
{
if(c==1629)
_asm nop;
for(d=0;d<5;d++)
doputlong(hdrLOD[c].uint[d],fp); // <<==== use hdrLOD[c].uint[0] - hdrLOD[c].uint[2] for dxl offset and size
}
if(hdr.nParent > MAX_PARENT)
hdr.nParent = MAX_PARENT;
doputlong(hdr.nParent,fp);// 16
for(c=0;c<hdr.nParent;c++)
{
if(hdrParent[c].uchar[3] > 100)
hdrParent[c].uchar[3] = 100;
if(hdrParent[c].ushort1[1] > 10)
hdrParent[c].ushort1[1] = 10;
if(hdrParent[c].uchar[0] > 10)
hdrParent[c].uchar[0] = 10;
for(d=0;d<7;d++)
doputfloat(hdrParent[c].f[d],fp);
for(d=0;d<2;d++)
doputlong(hdrParent[c].uint[d],fp);
for(d=0;d<2;d++)
doputshort(hdrParent[c].ushort1[d],fp);
for(d=0;d<4;d++)
doputchar(hdrParent[c].uchar[d],fp);
for(d=0;d<2;d++)
doputshort(hdrParent[c].ushort2[d],fp);
}
for(c=0;c<hdr.nParent;c++)
{
if(hdrParent[c].uchar[3] > 0)// Save Slots
{
for(d=0;d<hdrParent[c].uchar[3];d++)
{
doputfloat(hdrLODRes[c].slot1[d],fp);
doputfloat(hdrLODRes[c].slot2[d],fp);
doputfloat(hdrLODRes[c].slot3[d],fp);
}
}
if(hdrParent[c].ushort1[1] > 0)// Save Dynamic
{
for(d=0;d<hdrParent[c].ushort1[1];d++)
{
doputfloat(hdrLODRes[c].dyn1[d],fp);
doputfloat(hdrLODRes[c].dyn2[d],fp);
doputfloat(hdrLODRes[c].dyn3[d],fp);
}
}
if(hdrParent[c].uchar[0] > 0)// Save LOD indexes
{
for(d=0;d<hdrParent[c].uchar[0];d++)
{
//.........这里部分代码省略.........