#include <sys/stat.h>
TimeStamp
osgEarth::getLastModifiedTime(const std::string& path)
{
struct stat buf;
if ( stat(path.c_str(), &buf) == 0 )
return buf.st_mtime;
else
return 0;
}
获取文件最后修改时间
本文介绍了一种使用C++和sys/stat.h库获取文件最后修改时间的方法。通过使用stat函数和st_mtime字段,可以准确地获取到指定路径下文件的最后修改时间。
#include <sys/stat.h>
TimeStamp
osgEarth::getLastModifiedTime(const std::string& path)
{
struct stat buf;
if ( stat(path.c_str(), &buf) == 0 )
return buf.st_mtime;
else
return 0;
}

被折叠的 条评论
为什么被折叠?