本文整理汇总了C++中xfile::CFile::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::Close方法的具体用法?C++ CFile::Close怎么用?C++ CFile::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xfile::CFile
的用法示例。
在下文中一共展示了CFile::Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadCert
bool CWebServer::LoadCert(std::string &skey, std::string &scert)
{
XFILE::CFile file;
XFILE::auto_buffer buf;
const char* keyFile = "special://userdata/server.key";
const char* certFile = "special://userdata/server.pem";
if (!file.Exists(keyFile) || !file.Exists(certFile))
return false;
if (file.LoadFile(keyFile, buf) > 0)
{
skey.resize(buf.length());
skey.assign(buf.get());
file.Close();
}
else
CLog::Log(LOGDEBUG, "WebServer %s: Error loading: %s", __FUNCTION__, keyFile);
if (file.LoadFile(certFile, buf) > 0)
{
scert.resize(buf.length());
scert.assign(buf.get());
file.Close();
}
else
CLog::Log(LOGDEBUG, "WebServer %s: Error loading: %s", __FUNCTION__, certFile);
if (!skey.empty() && !scert.empty())
{
CLog::Log(LOGERROR, "WebServer %s: found server key: %s, certificate: %s, HTTPS support enabled", __FUNCTION__, keyFile, certFile);
return true;
}
return false;
}
示例2: Load
int CNfoFile::Load(const CStdString& strFile)
{
Close();
XFILE::CFile file;
if (file.Open(strFile))
{
m_size = (int)file.GetLength();
try
{
m_doc = new char[m_size+1];
m_headofdoc = m_doc;
}
catch (...)
{
CLog::Log(LOGERROR, "%s: Exception while creating file buffer",__FUNCTION__);
return 1;
}
if (!m_doc)
{
file.Close();
return 1;
}
file.Read(m_doc, m_size);
m_doc[m_size] = 0;
file.Close();
return 0;
}
return 1;
}
示例3: memset
TEST(TestFile, Write)
{
XFILE::CFile *file;
const char str[] = "TestFile.Write test string\n";
char buf[30];
memset(&buf, 0, sizeof(buf));
ASSERT_TRUE((file = XBMC_CREATETEMPFILE("")) != NULL);
file->Close();
ASSERT_TRUE(file->OpenForWrite(XBMC_TEMPFILEPATH(file), true));
EXPECT_EQ((int)sizeof(str), file->Write(str, sizeof(str)));
file->Flush();
EXPECT_EQ(0, file->GetPosition());
file->Close();
ASSERT_TRUE(file->Open(XBMC_TEMPFILEPATH(file)));
EXPECT_EQ(0, file->GetPosition());
EXPECT_EQ((int64_t)sizeof(str), file->Seek(0, SEEK_END));
EXPECT_EQ(0, file->Seek(0, SEEK_SET));
EXPECT_EQ((int64_t)sizeof(str), file->GetLength());
EXPECT_EQ(sizeof(str), file->Read(buf, sizeof(buf)));
file->Flush();
EXPECT_EQ((int64_t)sizeof(str), file->GetPosition());
EXPECT_TRUE(!memcmp(str, buf, sizeof(str)));
file->Close();
EXPECT_TRUE(XBMC_DELETETEMPFILE(file));
}
示例4: Get
bool CScraperUrl::Get(const SUrlEntry& scrURL, string& strHTML, CHTTP& http)
{
CURL url(scrURL.m_url);
http.SetReferer(scrURL.m_spoof);
CStdString strCachePath;
if (!scrURL.m_cache.IsEmpty())
{
CUtil::AddFileToFolder(g_advancedSettings.m_cachePath,"scrapers\\"+scrURL.m_cache,strCachePath);
if (XFILE::CFile::Exists(strCachePath))
{
XFILE::CFile file;
file.Open(strCachePath);
char* temp = new char[(int)file.GetLength()];
file.Read(temp,file.GetLength());
strHTML.append(temp,temp+file.GetLength());
file.Close();
delete[] temp;
return true;
}
}
if (scrURL.m_post)
{
CStdString strOptions = url.GetOptions();
strOptions = strOptions.substr(1);
url.SetOptions("");
CStdString strUrl;
url.GetURL(strUrl);
if (!http.Post(strUrl, strOptions, strHTML))
return false;
}
else if (!http.Get(scrURL.m_url, strHTML))
return false;
if (scrURL.m_url.Find(".zip") > -1)
{
XFILE::CFileZip file;
CStdString strBuffer;
int iSize = file.UnpackFromMemory(strBuffer,strHTML);
if (iSize)
{
strHTML.clear();
strHTML.append(strBuffer.c_str(),strBuffer.data()+iSize);
}
}
if (!scrURL.m_cache.IsEmpty())
{
CStdString strCachePath;
CUtil::AddFileToFolder(g_advancedSettings.m_cachePath,"scrapers\\"+scrURL.m_cache,strCachePath);
XFILE::CFile file;
if (file.OpenForWrite(strCachePath,true,true))
file.Write(strHTML.data(),strHTML.size());
file.Close();
}
return true;
}
示例5: Load
bool CKaraokeLyricsTextKAR::Load()
{
XFILE::CFile file;
bool succeed = true;
m_reportedInvalidVarField = false;
// Clear the lyrics array
clearLyrics();
if (file.LoadFile(m_midiFile, m_midiData) <= 0)
return false;
file.Close();
// Parse MIDI
try
{
parseMIDI();
}
catch ( const char * p )
{
CLog::Log( LOGERROR, "KAR lyrics loader: cannot load file: %s", p );
succeed = false;
}
m_midiData.clear();
return succeed;
}
示例6: Download
bool CCurlFile::Download(const CStdString& strURL, const CStdString& strFileName, LPDWORD pdwSize)
{
CLog::Log(LOGINFO, "Download: %s->%s", strURL.c_str(), strFileName.c_str());
CStdString strData;
if (!Get(strURL, strData))
return false;
XFILE::CFile file;
if (!file.OpenForWrite(strFileName, true))
{
CLog::Log(LOGERROR, "Unable to open file %s: %u",
strFileName.c_str(), GetLastError());
return false;
}
if (strData.size())
file.Write(strData.c_str(), strData.size());
file.Close();
if (pdwSize != NULL)
{
*pdwSize = strData.size();
}
return true;
}
示例7: item
// This test will fail until ActionDeleteFolder has a proper implementation
TEST(TestFileOperationJob, ActionDeleteFolder)
{
XFILE::CFile *tmpfile;
CStdString tmpfilepath, destpath;
CFileItemList items;
CFileOperationJob job;
ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE("")));
tmpfilepath = XBMC_TEMPFILEPATH(tmpfile);
tmpfile->Close();
destpath = tmpfilepath;
destpath += ".deletefolder";
ASSERT_FALSE(XFILE::CFile::Exists(destpath));
CFileItemPtr item(new CFileItem(destpath));
item->SetPath(destpath);
item->m_bIsFolder = true;
item->Select(true);
items.Add(item);
job.SetFileOperation(CFileOperationJob::ActionCreateFolder, items, destpath);
EXPECT_EQ(CFileOperationJob::ActionCreateFolder, job.GetAction());
EXPECT_TRUE(job.DoWork());
EXPECT_TRUE(XFILE::CDirectory::Exists(destpath));
job.SetFileOperation(CFileOperationJob::ActionDeleteFolder, items, destpath);
EXPECT_EQ(CFileOperationJob::ActionDeleteFolder, job.GetAction());
EXPECT_TRUE(job.DoWork());
EXPECT_FALSE(XFILE::CDirectory::Exists(destpath));
EXPECT_TRUE(XBMC_DELETETEMPFILE(tmpfile));
}
示例8: IsAnimated
bool Gif::IsAnimated(const char* file)
{
if (!m_dll.IsLoaded())
return false;
if (m_isAnimated < 0)
{
m_filename = file;
m_isAnimated = 0;
GifFileType* gif = nullptr;
XFILE::CFile gifFile;
if (!gifFile.Open(file) || !Open(gif, &gifFile, ReadFromVfs))
return false;
if (gif)
{
if (Slurp(gif) && gif->ImageCount > 1)
m_isAnimated = 1;
Close(gif);
gifFile.Close();
}
}
return m_isAnimated > 0;
}
示例9: while
TEST_F(TestRegExpLog, DumpOvector)
{
CRegExp regex;
CStdString logfile, logstring;
char buf[100];
unsigned int bytesread;
XFILE::CFile file;
logfile = CSpecialProtocol::TranslatePath("special://temp/") + "xbmc.log";
EXPECT_TRUE(CLog::Init(CSpecialProtocol::TranslatePath("special://temp/")));
EXPECT_TRUE(XFILE::CFile::Exists(logfile));
EXPECT_TRUE(regex.RegComp("^(?<first>Test)\\s*(?<second>.*)\\."));
EXPECT_EQ(0, regex.RegFind("Test string."));
regex.DumpOvector(LOGDEBUG);
CLog::Close();
EXPECT_TRUE(file.Open(logfile));
while ((bytesread = file.Read(buf, sizeof(buf) - 1)) > 0)
{
buf[bytesread] = '\0';
logstring.append(buf);
}
file.Close();
EXPECT_FALSE(logstring.empty());
EXPECT_STREQ("\xEF\xBB\xBF", logstring.substr(0, 3).c_str());
EXPECT_TRUE(regex.RegComp(".*DEBUG: regexp ovector=\\{\\[0,12\\],\\[0,4\\],"
"\\[5,11\\]\\}.*"));
EXPECT_GE(regex.RegFind(logstring), 0);
EXPECT_TRUE(XFILE::CFile::Delete(logfile));
}
示例10: Open
bool CJpegIO::Open(const CStdString &texturePath, unsigned int minx, unsigned int miny, bool read)
{
m_texturePath = texturePath;
unsigned int imgsize = 0;
XFILE::CFile file;
if (file.Open(m_texturePath.c_str(), 0))
{
imgsize = (unsigned int)file.GetLength();
m_inputBuff = new unsigned char[imgsize];
m_inputBuffSize = file.Read(m_inputBuff, imgsize);
file.Close();
if ((imgsize != m_inputBuffSize) || (m_inputBuffSize == 0))
return false;
}
else
return false;
if (!read)
return true;
if (Read(m_inputBuff, m_inputBuffSize, minx, miny))
return true;
return false;
}
示例11: CreateThumbnailFromSurface
bool COMXImage::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height,
unsigned int format, unsigned int pitch, const CStdString& destFile)
{
if(format != XB_FMT_A8R8G8B8 || !buffer) {
CLog::Log(LOGDEBUG, "%s::%s : %s failed format=0x%x\n", CLASSNAME, __func__, destFile.c_str(), format);
return false;
}
if(!Encode(buffer, height * pitch, width, height, pitch)) {
CLog::Log(LOGDEBUG, "%s::%s : %s encode failed\n", CLASSNAME, __func__, destFile.c_str());
return false;
}
XFILE::CFile file;
if (file.OpenForWrite(destFile, true))
{
CLog::Log(LOGDEBUG, "%s::%s : %s width %d height %d\n", CLASSNAME, __func__, destFile.c_str(), width, height);
file.Write(GetEncodedData(), GetEncodedSize());
file.Close();
return true;
}
return false;
}
示例12:
TEST(TestFileUtils, DeleteItemString)
{
XFILE::CFile *tmpfile;
ASSERT_NE(nullptr, (tmpfile = XBMC_CREATETEMPFILE("")));
tmpfile->Close(); //Close tmpfile before we try to delete it
EXPECT_TRUE(CFileUtils::DeleteItem(XBMC_TEMPFILEPATH(tmpfile)));
}
示例13: LoadFile
bool CPODocument::LoadFile(const std::string &pofilename)
{
XFILE::CFile file;
if (!file.Open(pofilename))
return false;
int64_t fileLength = file.GetLength();
if (fileLength < 18) // at least a size of a minimalistic header
{
file.Close();
CLog::Log(LOGERROR, "POParser: non valid length found for string file: %s", pofilename.c_str());
return false;
}
m_POfilelength = static_cast<size_t> (fileLength);
m_strBuffer.resize(m_POfilelength+1);
m_strBuffer[0] = '\n';
unsigned int readBytes = file.Read(&m_strBuffer[1], m_POfilelength);
file.Close();
if (readBytes != m_POfilelength)
{
CLog::Log(LOGERROR, "POParser: actual read data differs from file size, for string file: %s",
pofilename.c_str());
return false;
}
ConvertLineEnds(pofilename);
// we make sure, to have an LF at the end of buffer
if (*m_strBuffer.rbegin() != '\n')
{
m_strBuffer += "\n";
}
m_POfilelength = m_strBuffer.size();
if (GetNextEntry() && m_Entry.Type == MSGID_FOUND)
return true;
CLog::Log(LOGERROR, "POParser: unable to read PO file header from file: %s", pofilename.c_str());
return false;
}
示例14: Close
//========================================================================
int CFileURLProtocol::Close(AML_URLContext *h)
{
CLog::Log(LOGDEBUG, "CFileURLProtocol::Close");
XFILE::CFile *cfile = (XFILE::CFile*)h->priv_data;
cfile->Close();
delete cfile;
return 0;
}
示例15:
TEST(TestFile, Rename)
{
XFILE::CFile *file;
CStdString path1, path2;
ASSERT_TRUE((file = XBMC_CREATETEMPFILE("")) != NULL);
file->Close();
path1 = XBMC_TEMPFILEPATH(file);
ASSERT_TRUE((file = XBMC_CREATETEMPFILE("")) != NULL);
file->Close();
path2 = XBMC_TEMPFILEPATH(file);
EXPECT_TRUE(XFILE::CFile::Delete(path1));
EXPECT_FALSE(XFILE::CFile::Exists(path1));
EXPECT_TRUE(XFILE::CFile::Exists(path2));
EXPECT_TRUE(XFILE::CFile::Rename(path2, path1));
EXPECT_TRUE(XFILE::CFile::Exists(path1));
EXPECT_FALSE(XFILE::CFile::Exists(path2));
EXPECT_TRUE(XFILE::CFile::Delete(path1));
}