本文整理汇总了C++中FilePath::lastWriteTime方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::lastWriteTime方法的具体用法?C++ FilePath::lastWriteTime怎么用?C++ FilePath::lastWriteTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::lastWriteTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCacheableFile
void setCacheableFile(const FilePath& filePath,
const Request& request,
const Filter& filter)
{
// ensure that the file exists
if (!filePath.exists())
{
setError(http::status::NotFound, request.uri() + " not found");
return;
}
// set Last-Modified
using namespace boost::posix_time;
ptime lastModifiedDate = from_time_t(filePath.lastWriteTime());
setHeader("Last-Modified", util::httpDate(lastModifiedDate));
// compare file modified time to If-Modified-Since
if (lastModifiedDate == request.ifModifiedSince())
{
removeHeader("Content-Type"); // upstream code may have set this
setStatusCode(status::NotModified);
}
else
{
setFile(filePath, request, filter);
}
}
示例2: projectFromDirectory
FilePath projectFromDirectory(const FilePath& directoryPath)
{
// first use simple heuristic of a case sentitive match between
// directory name and project file name
FilePath projectFile = directoryPath.childPath(
directoryPath.filename() + ".Rproj");
if (projectFile.exists())
return projectFile;
// didn't satisfy it with simple check so do scan of directory
std::vector<FilePath> children;
Error error = directoryPath.children(&children);
if (error)
{
LOG_ERROR(error);
return FilePath();
}
// build a vector of children with .rproj extensions. at the same
// time allow for a case insensitive match with dir name and return that
std::string projFileLower = string_utils::toLower(projectFile.filename());
std::vector<FilePath> rprojFiles;
for (std::vector<FilePath>::const_iterator it = children.begin();
it != children.end();
++it)
{
if (!it->isDirectory() && (it->extensionLowerCase() == ".rproj"))
{
if (string_utils::toLower(it->filename()) == projFileLower)
return *it;
else
rprojFiles.push_back(*it);
}
}
// if we found only one rproj file then return it
if (rprojFiles.size() == 1)
{
return rprojFiles.at(0);
}
// more than one, take most recent
else if (rprojFiles.size() > 1 )
{
projectFile = rprojFiles.at(0);
for (std::vector<FilePath>::const_iterator it = rprojFiles.begin();
it != rprojFiles.end();
++it)
{
if (it->lastWriteTime() > projectFile.lastWriteTime())
projectFile = *it;
}
return projectFile;
}
// didn't find one
else
{
return FilePath();
}
}
示例3: recordSourcedFile
void SourceManager::recordSourcedFile(const FilePath& filePath, bool local)
{
SourcedFileInfo fileInfo(filePath.lastWriteTime(), local);
sourcedFiles_[filePath.absolutePath()] = fileInfo ;
}