本文整理汇总了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));
}
示例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;
}