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


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

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


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

示例1:

TEST(TestFile, Stat)
{
  XFILE::CFile *file;
  struct __stat64 buffer;

  ASSERT_TRUE((file = XBMC_CREATETEMPFILE("")) != NULL);
  EXPECT_EQ(0, file->Stat(&buffer));
  file->Close();
  EXPECT_TRUE(buffer.st_mode | _S_IFREG);
  EXPECT_EQ(-1, XFILE::CFile::Stat("", &buffer));
  EXPECT_EQ(ENOENT, errno);
  EXPECT_TRUE(XBMC_DELETETEMPFILE(file));
}
开发者ID:DasMarx,项目名称:xbmc,代码行数:13,代码来源:TestFile.cpp

示例2: SetFile

void CHTTPFileHandler::SetFile(const std::string& file, int responseStatus)
{
  m_url = file;
  m_response.status = responseStatus;
  if (m_url.empty())
    return;

  // translate the response status into the response type
  if (m_response.status == MHD_HTTP_OK)
    m_response.type = HTTPFileDownload;
  else if (m_response.status == MHD_HTTP_FOUND)
      m_response.type = HTTPRedirect;
  else
    m_response.type = HTTPError;

  // try to determine some additional information if the file can be downloaded
  if (m_response.type == HTTPFileDownload)
  {
    // determine the content type
    std::string ext = URIUtils::GetExtension(m_url);
    StringUtils::ToLower(ext);
    m_response.contentType = CMime::GetMimeType(ext);

    // determine the last modified date
    XFILE::CFile fileObj;
    if (!fileObj.Open(m_url, XFILE::READ_NO_CACHE))
    {
      m_response.type = HTTPError;
      m_response.status = MHD_HTTP_INTERNAL_SERVER_ERROR;
    }
    else
    {
      struct __stat64 statBuffer;
      if (fileObj.Stat(&statBuffer) == 0)
        SetLastModifiedDate(&statBuffer);
    }
  }

  // disable ranges and caching if the file can't be downloaded
  if (m_response.type != HTTPFileDownload)
  {
    m_canHandleRanges = false;
    m_canBeCached = false;
  }

  // disable caching if the last modified date couldn't be read
  if (!m_lastModified.IsValid())
    m_canBeCached = false;
}
开发者ID:68foxboris,项目名称:xbmc,代码行数:49,代码来源:HTTPFileHandler.cpp


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