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


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

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


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

示例1: 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;
}
开发者ID:grinnan,项目名称:xbmc-fork,代码行数:59,代码来源:ScraperUrl.cpp

示例2: while

/* The tests for XFILE::CFileFactory are tested indirectly through
 * XFILE::CFile. Since most parts of the VFS require some form of
 * network connection, the settings and VFS URLs must be given as
 * arguments in the main testsuite program.
 */
TEST_F(TestFileFactory, Read)
{
  XFILE::CFile file;
  std::string str;
  unsigned int size, i;
  unsigned char buf[16];
  int64_t count = 0;

  std::vector<std::string> urls =
    CXBMCTestUtils::Instance().getTestFileFactoryReadUrls();

  std::vector<std::string>::iterator it;
  for (it = urls.begin(); it < urls.end(); ++it)
  {
    std::cout << "Testing URL: " << *it << std::endl;
    ASSERT_TRUE(file.Open(*it));
    std::cout << "file.GetLength(): " <<
      testing::PrintToString(file.GetLength()) << std::endl;
    std::cout << "file.Seek(file.GetLength() / 2, SEEK_CUR) return value: " <<
      testing::PrintToString(file.Seek(file.GetLength() / 2, SEEK_CUR)) << std::endl;
    std::cout << "file.Seek(0, SEEK_END) return value: " <<
      testing::PrintToString(file.Seek(0, SEEK_END)) << std::endl;
    std::cout << "file.Seek(0, SEEK_SET) return value: " <<
      testing::PrintToString(file.Seek(0, SEEK_SET)) << std::endl;
    std::cout << "File contents:" << std::endl;
    while ((size = file.Read(buf, sizeof(buf))) > 0)
    {
      str = StringUtils::Format("  %08llX", count);
      std::cout << str << "  ";
      count += size;
      for (i = 0; i < size; i++)
      {
        str = StringUtils::Format("%02X ", buf[i]);
        std::cout << str;
      }
      while (i++ < sizeof(buf))
        std::cout << "   ";
      std::cout << " [";
      for (i = 0; i < size; i++)
      {
        if (buf[i] >= ' ' && buf[i] <= '~')
          std::cout << buf[i];
        else
          std::cout << ".";
      }
      std::cout << "]" << std::endl;
    }
    file.Close();
  }
}
开发者ID:AchimTuran,项目名称:xbmc,代码行数:55,代码来源:TestFileFactory.cpp

示例3: LoadXML

bool CGUIPythonWindowXML::LoadXML(const CStdString &strPath, const CStdString &strLowerPath)
{
  // load our window
  XFILE::CFile file;
  if (!file.Open(strPath) && !file.Open(CStdString(strPath).ToLower()) && !file.Open(strLowerPath))
  {
    // fail - can't load the file
    CLog::Log(LOGERROR, "%s: Unable to load skin file %s", __FUNCTION__, strPath.c_str());
    return false;
  }
  // load the strings in
  unsigned int offset = LoadScriptStrings();

  CStdString xml;
  char *buffer = new char[(unsigned int)file.GetLength()+1];
  if(buffer == NULL)
    return false;
  int size = file.Read(buffer, file.GetLength());
  if (size > 0)
  {
    buffer[size] = 0;
    xml = buffer;
    if (offset)
    {
      // replace the occurences of SCRIPT### with offset+###
      // not particularly efficient, but it works
      int pos = xml.Find("SCRIPT");
      while (pos != (int)CStdString::npos)
      {
        CStdString num = xml.Mid(pos + 6, 4);
        int number = atol(num.c_str());
        CStdString oldNumber, newNumber;
        oldNumber.Format("SCRIPT%d", number);
        newNumber.Format("%lu", offset + number);
        xml.Replace(oldNumber, newNumber);
        pos = xml.Find("SCRIPT", pos + 6);
      }
    }
  }
  delete[] buffer;

  TiXmlDocument xmlDoc;
  xmlDoc.Parse(xml.c_str());

  if (xmlDoc.Error())
    return false;

  return Load(xmlDoc);
}
开发者ID:Saddamisalami,项目名称:xbmc,代码行数:49,代码来源:GUIPythonWindowXML.cpp

示例4: 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;
}
开发者ID:A600,项目名称:xbmc,代码行数:26,代码来源:JpegIO.cpp

示例5: fileName

HRESULT CD3DEffect::Open(D3D_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes)
{
  XFILE::CFile includeFile;

  std::string fileName("special://xbmc/system/shaders/");
  fileName.append(pFileName);

  if (!includeFile.Open(fileName))
  {
    CLog::Log(LOGERROR, "%s: Could not open 3DLUT file: %s", __FUNCTION__, fileName.c_str());
    return E_FAIL;
  }

  int64_t length = includeFile.GetLength();
  void *pData = malloc(length);
  if (includeFile.Read(pData, length) != length)
  {
    free(pData);
    return E_FAIL;
  }
  *ppData = pData;
  *pBytes = length;

  return S_OK;
}
开发者ID:afedchin,项目名称:xbmc,代码行数:25,代码来源:D3DResource.cpp

示例6: 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));
}
开发者ID:DasMarx,项目名称:xbmc,代码行数:26,代码来源:TestFile.cpp

示例7: 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;
}
开发者ID:tmacreturns,项目名称:XBMC_wireless_setup,代码行数:29,代码来源:NfoFile.cpp

示例8: memset

TEST_F(TestZipFile, Read)
{
  XFILE::CFile file;
  char buf[20];
  memset(&buf, 0, sizeof(buf));
  std::string reffile, strpathinzip;
  CFileItemList itemlist;

  reffile = XBMC_REF_FILE_PATH("xbmc/filesystem/test/reffile.txt.zip");
  CURL zipUrl = URIUtils::CreateArchivePath("zip", CURL(reffile), "");
  ASSERT_TRUE(XFILE::CDirectory::GetDirectory(zipUrl, itemlist, "",
    XFILE::DIR_FLAG_NO_FILE_DIRS));
  EXPECT_GT(itemlist.Size(), 0);
  EXPECT_FALSE(itemlist[0]->GetPath().empty());
  strpathinzip = itemlist[0]->GetPath();
  ASSERT_TRUE(file.Open(strpathinzip));
  EXPECT_EQ(0, file.GetPosition());
  EXPECT_EQ(1616, file.GetLength());
  EXPECT_EQ(sizeof(buf), static_cast<size_t>(file.Read(buf, sizeof(buf))));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_TRUE(file.ReadString(buf, sizeof(buf)));
  EXPECT_EQ(39, file.GetPosition());
  EXPECT_STREQ("an award-winning fr", buf);
  EXPECT_EQ(100, file.Seek(100));
  EXPECT_EQ(100, file.GetPosition());
  EXPECT_EQ(sizeof(buf), static_cast<size_t>(file.Read(buf, sizeof(buf))));
  file.Flush();
  EXPECT_EQ(120, file.GetPosition());
  EXPECT_TRUE(!memcmp("ent hub for digital ", buf, sizeof(buf) - 1));
  EXPECT_EQ(220, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(220, file.GetPosition());
  EXPECT_EQ(sizeof(buf), static_cast<size_t>(file.Read(buf, sizeof(buf))));
  file.Flush();
  EXPECT_EQ(240, file.GetPosition());
  EXPECT_TRUE(!memcmp("rs, XBMC is a non-pr", buf, sizeof(buf) - 1));
  EXPECT_EQ(1596, file.Seek(-(int64_t)sizeof(buf), SEEK_END));
  EXPECT_EQ(1596, file.GetPosition());
  EXPECT_EQ(sizeof(buf), static_cast<size_t>(file.Read(buf, sizeof(buf))));
  file.Flush();
  EXPECT_EQ(1616, file.GetPosition());
  EXPECT_TRUE(!memcmp("multimedia jukebox.\n", buf, sizeof(buf) - 1));
  EXPECT_EQ(-1, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(1616, file.GetPosition());
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(sizeof(buf), static_cast<size_t>(file.Read(buf, sizeof(buf))));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(-1, file.Seek(-100, SEEK_SET));
  file.Close();
}
开发者ID:BigNoid,项目名称:xbmc,代码行数:54,代码来源:TestZipFile.cpp

示例9: dvd_file_seek

static offset_t dvd_file_seek(void *h, offset_t pos, int whence)
{
  if(interrupt_cb(NULL))
    return -1;

  XFILE::CFile *pFile = (XFILE::CFile *)h;
  if(whence == AVSEEK_SIZE)
    return pFile->GetLength();
  else
    return pFile->Seek(pos, whence & ~AVSEEK_FORCE);
}
开发者ID:hackedd,项目名称:omxplayer,代码行数:11,代码来源:OMXReader.cpp

示例10: memset

TEST(TestRarFile, Read)
{
  XFILE::CFile file;
  char buf[20];
  memset(&buf, 0, sizeof(buf));
  CStdString reffile, strrarpath, strpathinrar;
  CFileItemList itemlist;

  reffile = XBMC_REF_FILE_PATH("xbmc/filesystem/test/reffile.txt.rar");
  URIUtils::CreateArchivePath(strrarpath, "rar", reffile, "");
  ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strrarpath, itemlist, "",
    XFILE::DIR_FLAG_NO_FILE_DIRS));
  strpathinrar = itemlist[0]->GetPath();
  ASSERT_TRUE(file.Open(strpathinrar));
  EXPECT_EQ(0, file.GetPosition());
  EXPECT_EQ(1616, file.GetLength());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_TRUE(file.ReadString(buf, sizeof(buf)));
  EXPECT_EQ(39, file.GetPosition());
  EXPECT_STREQ("an award-winning fr", buf);
  EXPECT_EQ(100, file.Seek(100));
  EXPECT_EQ(100, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(120, file.GetPosition());
  EXPECT_TRUE(!memcmp("ent hub for digital ", buf, sizeof(buf) - 1));
  EXPECT_EQ(220, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(220, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(240, file.GetPosition());
  EXPECT_TRUE(!memcmp("rs, XBMC is a non-pr", buf, sizeof(buf) - 1));
  EXPECT_EQ(1596, file.Seek(-(int64_t)sizeof(buf), SEEK_END));
  EXPECT_EQ(1596, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(1616, file.GetPosition());
  EXPECT_TRUE(!memcmp("multimedia jukebox.\n", buf, sizeof(buf) - 1));
  EXPECT_EQ(1716, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(1716, file.GetPosition());
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(-1, file.Seek(-100, SEEK_SET));
  file.Close();
}
开发者ID:A600,项目名称:xbmc,代码行数:52,代码来源:TestRarFile.cpp

示例11: SeekEx

//========================================================================
int64_t CFileURLProtocol::SeekEx(URLContext *h, int64_t pos, int whence)
{
  XFILE::CFile *cfile = (XFILE::CFile*)h->priv_data;

  // seek to the end of file
  if (whence == AVSEEK_SIZE)
    pos = cfile->GetLength();
  else
    pos = cfile->Seek(pos, whence & ~AVSEEK_FORCE);

  printf("CFileURLProtocol::SeekEx pos(%lld), whence(%d)\n", pos, whence);

  return pos;
}
开发者ID:achellies,项目名称:xbmc-android-old,代码行数:15,代码来源:FileURLProtocol.cpp

示例12: SeekEx

//========================================================================
int64_t CFileURLProtocol::SeekEx(AML_URLContext *h, int64_t pos, int whence)
{
  //CLog::Log(LOGDEBUG, "CFileURLProtocol::SeekEx1 pos(%lld), whence(%d)", pos, whence);
  XFILE::CFile *cfile = (XFILE::CFile*)h->priv_data;
  whence &= ~AVSEEK_FORCE;

  // seek to the end of file
  if (pos == -1 || whence == AVSEEK_SIZE)
    pos = cfile->GetLength();
  else
    pos = cfile->Seek(pos, whence);

  //CLog::Log(LOGDEBUG, "CFileURLProtocol::SeekEx2 pos(%lld), whence(%d)", pos, whence);

  return pos;
}
开发者ID:Inferno1977,项目名称:xbmc,代码行数:17,代码来源:FileURLProtocol.cpp

示例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;
}
开发者ID:OV3RDOSE,项目名称:xbmc,代码行数:45,代码来源:POUtils.cpp

示例14: Load

bool CKaraokeLyricsTextKAR::Load()
{
  XFILE::CFile file;
  bool succeed = true;
  m_reportedInvalidVarField = false;

  // Clear the lyrics array
  clearLyrics();

  if ( !file.Open( m_midiFile ) )
    return false;

  m_midiSize = (unsigned int) file.GetLength();

  if ( !m_midiSize )
    return false;  // shouldn't happen, but

  file.Seek( 0, SEEK_SET );

  m_midiData = new unsigned char [ m_midiSize ];

  // Read the whole file
  if ( !m_midiData || file.Read( m_midiData, m_midiSize) != m_midiSize )
    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;
  }

  delete [] m_midiData;
  m_midiData = 0;
  return succeed;
}
开发者ID:AWilco,项目名称:xbmc,代码行数:42,代码来源:karaokelyricstextkar.cpp

示例15: Load

HRESULT CNfoFile::Load(const CStdString& strFile)
{
  Close();
  XFILE::CFile file;
  if (file.Open(strFile, true))
  {
    m_size = (int)file.GetLength();
    m_doc = new char[m_size+1];
    if (!m_doc)
    {
      file.Close();
      return E_FAIL;
    }
    file.Read(m_doc, m_size);
    m_doc[m_size] = 0;
    file.Close();
    return S_OK;
  }
  return E_FAIL;
}
开发者ID:jimmyswimmy,项目名称:plex,代码行数:20,代码来源:NfoFile.cpp


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