Introduce Utility::GetModTime()

refs #8210
This commit is contained in:
Alexander A. Klimov 2020-09-07 16:55:02 +02:00
parent f6db26f683
commit 71e19c4d01
2 changed files with 21 additions and 0 deletions

View File

@ -1306,6 +1306,26 @@ bool Utility::PathExists(const String& path)
return fs::exists(fs::path(path.Begin(), path.End()), ec) && !ec;
}
double Utility::GetModTime(const String& path)
{
#ifndef _WIN32
struct stat statbuf;
if (stat(path.CStr(), &statbuf) < 0) {
#else /* _WIN32 */
struct _stat statbuf;
if (_stat(path.CStr(), &statbuf) < 0) {
#endif /* _WIN32 */
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("stat")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(path));
}
return statbuf.st_mtime;
}
Value Utility::LoadJsonFile(const String& path)
{
std::ifstream fp;

View File

@ -111,6 +111,7 @@ public:
static tm LocalTime(time_t ts);
static bool PathExists(const String& path);
static double GetModTime(const String& path);
static void Remove(const String& path);
static void RemoveDirRecursive(const String& path);