本文整理汇总了C++中CFile::LoadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::LoadFile方法的具体用法?C++ CFile::LoadFile怎么用?C++ CFile::LoadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::LoadFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnJobComplete
void CGUIDialogAddonInfo::OnJobComplete(unsigned int jobID, bool success,
CJob* job)
{
if (!m_changelog)
return;
CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
m_jobid = 0;
if (!success)
{
pDlgInfo->SetText(g_localizeStrings.Get(195));
}
else
{
CFile file;
XFILE::auto_buffer buf;
if (file.LoadFile("special://temp/" +
URIUtils::GetFileName(((CFileOperationJob*)job)->GetItems()[0]->GetPath()), buf) > 0)
{
std::string str(buf.get(), buf.length());
m_item->SetProperty("Addon.Changelog", str);
pDlgInfo->SetText(str);
}
}
CGUIMessage msg(GUI_MSG_NOTIFY_ALL, WINDOW_DIALOG_TEXT_VIEWER, 0, GUI_MSG_UPDATE);
g_windowManager.SendThreadMessage(msg);
}
示例2: GetPrivacyPolicy
std::string CSysInfo::GetPrivacyPolicy()
{
if (m_privacyPolicy.empty())
{
CFile file;
XFILE::auto_buffer buf;
if (file.LoadFile("special://xbmc/privacy-policy.txt", buf) > 0)
{
std::string strBuf(buf.get(), buf.length());
m_privacyPolicy = strBuf;
}
else
m_privacyPolicy = g_localizeStrings.Get(19055);
}
return m_privacyPolicy;
}
示例3: LoadTexture
IGfxTexture2D* COGLDevice::LoadTexture( const char* szFilename )
{
COGLTexture2D* pTexture = new COGLTexture2D;
glGenTextures( 1, (GLuint*)&pTexture->m_nTexture );
// TODO: read in the texture file contents
CFile fTextureFile;
fTextureFile.LoadFile( szFilename, "rb" );
GLbyte* pTextureBits;
// uint nTotalRead = fTextureFile.ReadBytes( pTextureBits, <#uint nNumBytes#>);
sint nTexWidth;
sint nTexHeight;
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nTexWidth, nTexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTextureBits );
return pTexture;
}
示例4: Process
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")) &&
!g_application.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.GetServerReportedCharset();
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();
}